Jaime Garcia had his second bad start in a row for the Braves on Thursday night, but by 12:30 a.m. it had become a footnote, overshadowed by a fifth-inning avalanche of Atlanta offense and some shaky Atlanta defense and bullpen work as the Braves nearly blew all of a six-run lead lead.

They hung on for a 12-11 win against the San Francisco Giants, who are a shadow of that franchise’s recent World Series championship teams, giving the Braves a 7-3 record in their past 10 games and three consecutive series wins.

Nick Markakis had four hits including a home run and the Braves also got home runs from Brandon Phillips and two from Adams – one apiece from Matt Adams and Lane Adams, his first in the majors – in the finale of a soggy four-game series at SunTrust Park.

The Braves overcame an early 5-2 deficit, took a 12-6 lead with an eight-run fifth inning, then gave up five runs in the last two innings before closer Jim Johnson got Hunter Pence to ground out with two on to end the game. Whew.

“Oh my God, you talk about a rollercoaster of emotions,” Braves manager Brian Snitker said. “That’s baseball. It just happens. You don’t know why…. Teams aren’t going to lay down. We came roaring back, they came roaring back. I thought J.J. (Johnson) did a great job that inning staying focused and in control. A couple of mis-hit base hits and then we screw up a ground ball and put a lot of pressure on him.

“But the guys hung in there. Hung in there and had the big (fifth) inning. It’s a good win.”

Phillips (groin tightness) and Matt Kemp (hamstring tightness) left the game for precautionary reasons, Snitker said. Phillips said he expected to play Friday's series opener against Milwaukee.

The Braves captured a season series against the Giants for the first time since 2011, winning four of seven games. The Giants have lost 18 of 23 including seven of eight on the trip they ended Thursday.

Atlanta trailed 6-4 before an nine-hit outburst in the fifth inning that included a leadoff homer from Phillips followed by five consecutive singles, a sacrifice fly and a three-run pinch-hit homer from Lane Adams, a 27-year-old rookie whose only major league experience before this season was three plate appearances with the Royals in 2014.

“Looking back at it, it’s probably better than I ever thought,” said Adams, who launched a no-doubt-about it shot to the second seating deck in left field. “I mean, I imagined it’d be a great feeling, but once it happens it’s even better than you imagined.”

Making it all the more special, he said, was having his mother, Shelley, and two nieces in attendance after they drove from Oklahoma on Wednesday. It was the first time his nieces saw him play in the majors.

The Braves gave up two unearned runs in a three-run eighth after a Lane Adams error in left field, and two runs in a sloppy ninth that saw second baseman turn a potential double play into a no-out play when he waited to long to throw to first after initially trying to tag a runner between first and second.

But they held on and improved to 12-9 in June with a National League-best 120 runs scored during the month.

“It feels good just to see the team go in there swinging the bat the way we did today,” Phillips said. “It seems like we like to make the game interesting sometimes, but like I say, it feels good just to have us out there swinging the bat the way we did in that one inning.”

They collected seven runs and seven hits in the fifth inning before the Giants recorded a second out.

“They say hitting’s contagious and I believe it is,” Lane Adams said. “Once a couple of guys get going everyone falls in line, and that’s what it takes. You wish you could have those innings every inning, but that’s not baseball. But yeah, it was a great inning.”

The start of the game was delayed 1 hour and 26 minutes, the league-leading eighth rain delay for the Braves this season including their third in the four-game series that ended Thursday.

Giants starter Matt Cain (3-7) gave up 10 hits including a season-high three homers and nine runs in four-plus innings and left without recording an out in the fifth. The veteran gave up the first three hits of the fifth including the Phillips homer, after serving up Markakis’ two-run drive in the first inning and Matt Adams’ leadoff shot in the fourth.

Braves left-hander Garcia, after not giving up more than four runs all season, has allowed six runs in consecutive starts against the Marlins and Giants on this homestand. He lasted 4 1/3 innings Thursday and allowed seven hits (four doubles, two homers), six runs and three walks with three strikeouts.

“Jaime just wasn’t on today,” Snitker said. “The ball wasn’t sinking and he was kind of getting the ball up. It happens.”

In his past two starts, Garcia has allowed 17 hits, 12 runs (all earned) and five walks in 10 innings. This after posting a 3.21 ERA in his first 11 starts including a 2.75 ERA in his last nine starts before this homestand.

Matt Adams fourth-inning homer and run-scoring single in the fifth gave him 12 homers and 31 RBIs in 31 games for the Braves since arriving in a trade from St. Louis to serve as Freddie Freeman’s fill-in while he healed from a fractured wrist. Adams tied Justin Upton (2013) for most homers in franchise history in a player’s first 31 games for the Braves.

He has six homers and 16 RBIs in his past 10 games and 20 of his 37 total hits for the Braves have been extra-base hits.

Adams has been so good that Freeman offered to move to third base in order to keep Adams in the lineup when Freeman returns from the disabled list, which is expected to be in two or three weeks. The Braves agreed the idea made sense and Freeman, a former high school third baseman who last played the position for five games in rookie ball in 2007, started working out at third base this week and plans to play that position when he's activated.

The Braves staked Garcia to a 2-0 lead in the first inning when Ender Inciarte led off with a single and Markakis homered with one out. But Garcia gave the lead back and more in the next inning as the Giants scored three runs in the second inning including a leadoff homer from South Georgia native Buster Posey.

After intentionally walking Gorkys Hernandez with a runner at hird to bring up Cain with two outs, Garcia grooved a pitch down the middle that the pitcher hit for a two-run opposite-field double off the right-field wall.