SAN FRANCISCO — The Giants combined some unexpected power at the plate with a gritty outing from Madison Bumgarner to beat the Braves and finally get a much-needed series win — a rarity for manager Bruce Bochy's ballclub since the All-Star break.

With a little more than a month left in the season, even hitting four home runs, including a pair by Joe Panik, paled in comparison to taking two of three from Atlanta.

"There haven't been many of them in the second half, but things look like they're starting to turn around for us," Bumgarner said after pitching seven innings in San Francisco's 13-4 victory Sunday. "We've been playing pretty good but a lot of things haven't gone our way. That's a good win for us, to win that series."

The Giants had won only one series since the break. In the process, a 6 1/2-game lead in the NL West turned into a two-game deficit heading into Sunday.

San Francisco is still two games back of the first-place Los Angeles Dodgers, but the outlook sure is a lot brighter after the Giants completed their first series win at home since early July.

"It's great to take any series," Bochy said. "Hopefully, we can come back and carry this the rest of the way.

Panik hit a solo homer in the second and added a two-run shot in the fourth. The second baseman also reached on an infield single in the sixth and had a sacrifice fly in the seventh to match his career high of four RBIs.

It was the first multihomer game of his career.

"It was a combination of getting some good counts where I can be aggressive and just not missing those spots," Panik said.

Denard Span and Eduardo Nunez also homered for the Giants. Brandon Crawford had three hits and Jarrett Parker drove in three runs.

Three of San Francisco's four homers came off Braves starter Aaron Blair (0-6), who allowed five runs over four innings.

"When I kept the ball down they were effective pitches, and when I got hurt they were up and flat," Blair said.

Bumgarner (13-8) allowed three runs over seven uneven innings. He struck out five and walked two.

San Francisco's four-time All-Star pitched in and out of trouble most of the day but punctuated his afternoon with an emphatic fist pump after striking out pinch-hitter Jace Peterson to end the seventh.

"It seemed like it was ball one to every hitter," Bumgarner said. "My command was good, just not the first pitch of the at-bat it seemed like."

Freddie Freeman and Gordon Beckham homered for Atlanta. Ender Inciarte doubled, tripled and scored twice, but the last-place Braves have lost 13 of 18.

Nunez, who had three hits, homered as part of an eight-run seventh, when the Giants tripled three times and sent 14 batters to the plate.

MAKING HISTORY

The Giants had not had four home runs and four triples in one game since at least 1900. The last major league team to do it was the New York Yankees against Texas on May 6, 1998. Three triples came in one inning, the first time in San Francisco history that the Giants have done that.

TRAINER'S ROOM

Braves: RHP John Gant was optioned to Triple-A Gwinnett to make room for Blair.

Giants: 1B Brandon Belt was in the lineup after being a late scratch Saturday because of a stiff neck. ... OF Hunter Pence missed his third consecutive game with tightness in his right hamstring. ... Giants reliever Derek Law was placed on the 15-day disabled list with a strained right elbow. ... Parker was called up from Triple-A Sacramento before the game.

UP NEXT

Braves: RHP Julio Teheran (3-9) pitches against San Diego on Tuesday in the opener of a brief, three-game homestand. Teheran is winless since June 19.

Giants: RHP Johnny Cueto (14-4) faces Arizona for the fourth time this season Tuesday at AT&T Park. Cueto has two wins and a 3.86 ERA in his previous three games against the Diamondbacks.