ATLANTA -- Adonis Garcia doesn't hit a ton of home runs, but when he does go deep, he tends to pick important moments.
All three of Garcia's homers gave the Braves a lead, and this one produced the team's ninth victory in its final at-bat.
"Garcia at the end ... he's hit three (home runs), all to right-center or straightaway center," Atlanta manager Fredi Gonzalez said. "There haven't been any cheap ones."
"Give the kid credit," San Francisco manager Bruce Bochy said. "He drove the ball out in the big part of the ballpark."
The Giants took an 8-7 lead in the top of 12th on an RBI single by catcher Buster Posey.
With one out in the 12th, San Francisco rookie Kelby Tomlinson made his major league debut with a pinch-hit single against Ross Detwiler. The Washington reliever followed that by hitting center fielder Gregor Blanco with a pitch.
The Braves brought in hard-throwing Arodys Vizcaino (2-0), who gave up a long fly to center that allowed Tomlinson to advance to third base. Posey then laced a single into right-center field to drive in the go-ahead run.
The Braves sent the game into extra innings when catcher A.J. Pierzynski hit a two-run homer, his seventh, against San Francisco closer Santiago Casilla with two outs in the ninth inning. That tied the game, which San Francisco once led 6-0, at 7-7.
"You got two outs with Casilla, you like your chances," Bochy said. "But he made a mistake, and (Pierzynski) made us pay."
Gonzalez said, "(Pierzynski is) dangerous. He's got pop. He's going to give you a good at-bat."
Pierzynski had four of Atlanta's 17 hits, which matched a season high. It was the fourth time in five games that Atlanta collected at least 10 hits. It was the team's biggest comeback of the season and biggest since erasing a six-run deficit in 2012.
The Giants hit four home runs, two of them by shortstop Brandon Crawford and one each by first baseman Brandon Belt and Posey.
San Francisco starter Matt Cain allowed 10 hits in his five-plus innings but never retired the side in order. He aided by two double plays, and he escaped unscathed until the sixth. That was when the Braves rallied for four runs, with Peterson's three-run homer being the big blow.
Garcia followed the homer with a double down the line, which chased Cain. Reliever George Kontos retired the next two batters before allowing an RBI single to right fielder Nick Markakis that cut the lead to 6-4.
Atlanta drew to within one in the seventh when first baseman Chris Johnson hit a long solo homer to center field, his second, against reliever Hunter Strickland.
"They battled back," Bochy said. "Credit to them. They kept coming at us."
The Giants added a run in the ninth against reliever Andrew McKirahan. Left fielder Nori Aoki singled with two outs to drive in second baseman Ehire Adrianza to make it 7-5.
Atlanta starter Mike Foltynewicz allowed a career-high six runs on nine hits and one walk in six innings.
The Giants hit back-to-back solo homers in the second inning and took a 2-0 lead. Belt clubbed his 13th homer and Crawford hit his 17th, both just out of the reach of left fielder Eury Perez.
San Francisco added two runs in the third on a two-run shot by Posey, who drove the ball 414 feet to straightaway center field. With his fifth career homer against Atlanta, Posey extended his road hitting streak to 15 games.
In the fourth, Crawford hit his second homer of the night, his 18th. The two-run shot just cleared the wall in left field gave the Giants a 6-0 lead.
"I'm really proud of our team for not giving up," Gonzalez said. "You keep battling."
Atlanta first baseman Freddie Freeman left the game after the fourth inning with a right oblique strain. Freeman was activated July 25 after missing 30 games with a bruised right wrist.
NOTES: The Giants placed 2B Joe Panik on the 15-day disabled list, retroactive to Sunday, due to lower-back inflammation. Panik will fly back to San Francisco and be examined by team doctors but is expected to be activated as soon as he is eligible. The Giants recalled rookie 2B Kelby Tomlinson from Triple-A Sacramento. Tomlinson batted .321 in 97 games split between Sacramento and Double-A Richmond. ... San Francisco OF Angel Pagan (right knee soreness) was scratched from the lineup, though he appeared as a pinch hitter. Manager Bruce Bochy said he would rest Pagan until the Giants face a left-handed starter. ... Atlanta SS Andrelton Simmons (sprained right thumb) missed his second consecutive start. Simmons was injured diving for a ball Saturday. X-rays revealed no fracture. He had an MRI exam Monday and the Braves are now calling it a bone bruise. ... Starters for Tuesday: San Francisco RHP Jake Peavy (2-4, 4.12 ERA) vs. Atlanta RHP Shelby Miller (5-8, 2.44).