Kevin Gausman, pinch-hitting because San Francisco had run out of position players on the bench, lifted a walk-off sacrifice fly in the 11th inning Friday night as the Giants outlasted the visiting Atlanta Braves 6-5.
The matchup of division leaders saw both teams hit game-extending home runs inthe ninth inning.
The Giants (96-52) snapped a two-game losing streak and extended their lead over the second-place Los Angeles Dodgers (94-54) to two games in the National League West.
Meanwhile, the Braves (76-69) took a third straight defeat and lost a game off their advantage in the NL East. They lead the Philadelphia Phillies (75-72) by just two games.
Gausman was summoned off the bench to face Jacob Webb (4-3) after the Braves intentionally walked Evan Longoria and Donovan Solano, with a short flyout in between.
A .184 hitter this season, Gausman extended Webb to a full count before hitting a fly just deep enough into right field that Brandon Crawford could beat Joc Pederson's throw to the plate for the Giants' fourth walk-off win of the season.
Camilo Doval (3-1), who pitched a scoreless top of the 11th, was credited with the win.
Both teams rallied from deficits in the ninth to send the game onward.
After home runs by Brandon Belt, Crawford and LaMonte Wade Jr. had given the Giants a 4-2 lead heading to the ninth, Travis d'Arnaud launched a go-ahead, three-run shot off Tyler Rogers with one out to put Atlanta in front 5-4.
Braves closer Will Smith then got within one strike of his 33rd save before Solano, pinch-hitting for Mike Yastrzemski, tied the game with a blast to left.
Both d'Arnaud and Solano collected their seventh homer of the season.
Despite giving up two runs among the first five hitters he faced, Giants starter Logan Webb was two outs away from recording his 10th straight win before Rogers served up d'Arnaud's homer. He wound up retiring 19 of the last 22 batters he faced, finishing seven innings with six hits and two runs allowed. He struck out nine and did not issue a walk.
After Adam Duvall's two-out, two-run double in the top of the first gave the Braves a quick lead, the Giants needed just 10 pitches to draw even on a Darin Ruf walk and a two-run homer by Belt, his 26th of the season.
Crawford led off the second with his 21st homer, a solo shot off Braves starter Ian Anderson, before Wade crushed his 18th homer into the San Francisco Bay in the fourth for a 4-2 lead.
Anderson worked 5 2/3 innings, charged with four runs on five hits. He walked two and struck out seven.
Crawford had two hits and scored twice for the Giants, who improved to 10-7 in extra-inning affairs.
Austin Riley, Duvall and Freddie Freeman collected two hits apiece for the Braves, who were opening a 10-game Western swing.
--Field Level Media