Paul DeJong and Randal Grichuk hit back-to-back home runs off Jon Lester (7-6) in the eighth inning to put the Cardinals ahead. DeJong smacked a two-out solo shot to left field for his 11th of the season before Grichuk connected on his 11th.
Cardinals starter Adam Wainwright threw seven scoreless innings before being charged with two runs in the eighth. He gave up four hits and no walks and struck out three.
Giants 5, Padres 4 (12)
SAN FRANCISCO -- Nick Hundley drove in Kelby Tomlinson with a single to the base of the fence in left field with two outs in the 12th inning, giving San Francisco a victory over San Diego.
Eduardo Nunez drove in two runs with three hits and the San Francisco bullpen pitched six innings of one-hit ball, helping the Giants beat the Padres for just the second time in their last nine meetings at AT&T Park.
Wil Myers homered for the second straight day for the Padres, who posted a 12-9, 11-inning win over the Giants on Friday.