SAN FRANCISCO — Michael Wacha is never surprised that the St. Louis Cardinals find a way to come back even if behind big early.
They nearly did it again against postseason nemesis San Francisco before rookie Kelby Tomlinson lined a game-winning single in the ninth against a five-man infield, lifting the defending champion Giants to a 5-4 victory Friday night that snapped St. Louis' five-game winning streak.
Marlon Byrd hit a grand slam off 15-game winner Wacha in the third inning for the Giants, who kept pace 2 1/2 games behind NL West-leading Los Angeles.
"There's never a doubt in our dugout. After that four-spot came in, the energy was just as high as it always is," Wacha said. "They went up and put up a three-spot right after that. Great bounce-back inning, got us right back in the game. That's awesome to see as a pitcher."
Tomlinson found a hole against previously unbeaten Kevin Siegrist (5-1). Moments earlier, left fielder Brandon Moss grabbed another glove from the dugout and moved in to make a five-man infield.
Javier Lopez (1-0) got Moss to line out to second in the ninth and Tomlinson quickly fired to first to double up Stephen Piscotty, who was off the bag.
"Let's not overlook, too, the fact we were down four in this game," Cardinals manager Mike Matheny said. "It was a great job of getting us back into this. Just couldn't get a whole lot going."
Byrd's eighth career grand slam gave the Giants eight for the season, a franchise record. Byrd last hit one on July 9, 2013, while with the Mets facing the Giants at AT&T Park.
"This one's a lot bigger," Byrd said. "It's a pennant race and the Dodgers already won. We needed this win tonight to stay on pace."
Cardinals rookie Piscotty, who played at Stanford and grew up in nearby Pleasanton, hit a two-run double in the fourth as St. Louis pulled back within 4-3. The right fielder robbed Matt Duffy in the sixth with a diving catch that took him over the bullpen mound.
Piscotty had 60 friends, family and old coaches in the stands rooting for him.
The scoreboard went out for about four minutes and the ballpark lights briefly flickered twice.
Byrd, previously 0 for 17 against Wacha, sent the first pitch he saw in the third over the wall in center field moments after Buster Posey was hit on the left elbow to load the bases against the team with baseball's best record.
"I've had a tough time against Wacha," Byrd said. "That's my only hit in my career, a lot of strikeouts. He's tough. I got one pitch to do something with and put a good swing on it."
Wacha surrendered an even more memorable shot more than 10 months ago.
Travis Ishikawa's improbable walkoff three-run homer clinched the NL pennant for the Giants with a 6-3 Game 5 win against the Cardinals in the NLCS at AT&T Park last October.
Mike Leake retired the first nine batters in order but is still missing his first win after three starts since joining the Giants in a trade from Cincinnati on July 30.
Josh Osich relieved Leake with runners on first and second and one out in the seventh, then retired pinch-hitter Jason Heyward and Matt Carpenter.
The Cardinals tied it on Leake's wild pitch in the top of the sixth.
St. Louis, which turned nine double plays in its recent four-game sweep at Arizona, committed two errors in the Giants' big third that made all four runs unearned.
Cardinals: Matt Belisle, on the DL since June 26 with right elbow inflammation, threw a bullpen session. ... OF Matt Holliday (strained right quadriceps muscle) is scheduled to be re-evaluated this weekend in St. Louis. ... Closer Trevor Rosenthal was placed on the paternity leave list and recalled RHP Sam Tuivailala from Triple-A Memphis.
Cardinals: RHP Lance Lynn (10-8) tries again for his first career regular-season victory against the Giants after beginning 0-4 with a 6.33 ERA in his previous four starts — and 0-1 in three postseason starts. The Cardinals managed only two hits in his start last week at Busch Stadium, a 2-0 loss. He has never pitched at AT&T Park in the regular season.
Giants: RHP Ryan Vogelsong (9-9) looks to bounce back from a start of 3 1/3 innings his last time out at Pittsburgh. He pitched opposite Lynn on Aug. 18, tossing six shutout innings to improve to 3-6 in the regular season vs. St. Louis.