ST. LOUIS (AP) Kevin Pillar had four hits, including a go-ahead, two-run homer in the eighth inning, and the San Francisco Giants rallied to cool off the St. Louis Cardinals 9-8 Wednesday night.
Brandon Crawford and Mike Yastrzemski also homered for San Francisco, which snapped a four-game losing streak.
Paul Goldschmidt drove in four runs and Paul DeJong homered for St. Louis, which lost for just the fourth time in 18 games. St. Louis remained 2 1/2 games ahead of the Chicago Cubs in the NL Central.
Pillar had three RBIs. He hit a two-run homer off Giovanny Gallegos in the eighth.
Will Smith recorded four outs for his 31st save in 35 chances. He struck out Goldschmidt with the tying run at third to end the eighth, then punched out Harrison Bader with two on to end the game.
Goldschmidt hit a two-run triple in the fifth to tie it at 4. He also highlighted a four-run outburst in the sixth with a two-run double to give St. Louis an 8-7 lead.
Rookie right-hander Tyler Rogers (1-0) got his first career victory with 1 1/3 innings of scoreless relief.
Gallegos (3-2) went two months and 19 appearances without allowing a homer before giving up Giants rookie Mauricio Dubon's solo shot Monday. This was his first appearance since then.
Evan Longoria started the eighth-inning comeback with a leadoff single to set the stage for Pillar's 21st homer of the season.
The Giants held leads of 4-0 and 7-4. Crawford hit a three-run homer in sixth to break a 4-4 tie.
San Francisco starter Madison Bumgarner allowed six runs and nine hits over five innings. He struck out two and walked one.
St. Louis starter Michael Wacha, working on three days rest, did not allow a run over two innings. He gave up two hits, struck out two and walked one in an opener role.
DeJong's 25th homer of the season in the fourth pulled St. Louis within 4-2. Yastrzemski's 19th homer of the season triggered a four-run outburst in third.