CHICAGO (AP) -- The St. Louis Cardinals were headed for another heartbreaking loss when Carlos Beltran turned it around with one big swing.
When Beltran got back to the dugout, starting pitcher Adam Wainwright showed his appreciation for the timely play.
''I kissed him right on the cheek. I'm not afraid to tell the whole world, either,'' Wainwright said. ''I wanted to kiss him on the mouth. He saved me, he saved the team today.''
Beltran hit a tying solo homer in the ninth and Jon Jay doubled in the winning run an inning later as the Cardinals bolstered their bid for another playoff appearance with a 5-4 victory over the Chicago Cubs on Saturday.
St. Louis increased its lead for the second NL wild card to 2 1/2 games over Milwaukee, which lost 10-4 at Washington. The Los Angeles Dodgers are three back following a 6-0 loss at Cincinnati.
The defending World Series champion Cardinals have 10 games left in the regular season. They bounced back from an agonizing 11-inning loss at Wrigley Field the previous day.
After Matt Carpenter and Brian Anderson drew two-out walks from Jaye Chapman (0-1), Jay doubled down the right-field line.
''If we'd have lost that game, I don't think I'd sleep at all tonight,'' Wainwright said.
Mitchell Boggs (4-1) got the last out of the ninth. Jason Motte struck out the side in the 10th for his 39th save.
Beltran connected for his 30th homer, a one-out shot off Carlos Marmol that wrapped just inside the right-field foul pole. Marmol had been successful on 19 straight save chances dating to May 2.
''It's no secret you're going to get a fastball and you're gonna get a slider,'' Beltran said. ''We were trying to put ourselves in a position to at least score a run. I was able to get a pitch to hit. In my mind, I'm just trying to put myself on the basepaths.''
Before Beltran's drive, it appeared the Cardinals were going to blow another game against their arch rival in the most crucial time of the season.
St. Louis lost in dramatic fashion on Friday. Fernando Salas gave up a two-out, two-strike, two-run homer to Darwin Barney in the ninth to send the game to extra innings, and the Cubs won 5-4 in 11 on David DeJesus' RBI single.
Both Boggs and Motte were unavailable.
''It was tough yesterday not putting (Boggs and Motte) in there, but we're gonna have to do that,'' Cardinals manager Mike Matheny said. ''There are gonna be days where someone else has to step up.''
On Matheny's 42nd birthday, St. Louis improved to 10-10 in September after going 18-8 in the final month last season, when the Cardinals squeezed into the playoffs on the final day of the season.
DeJesus' solo homer started a three-run rally in the sixth as Chicago nearly came from behind to knock off the Cardinals for a second straight day.
Travis Wood again failed to win at Wrigley, though he held St. Louis to two earned runs over five innings, striking out seven. He entered with an 0-5 record and a 6.08 ERA over his last seven home starts, but finished with a no-decision when the Cubs rallied.
''Every win counts. We're battling as hard as we can,'' Wood said. ''We played pretty good today. We ended up taking a lead, just couldn't hold them off. That's a good team over there.''
All-Star catcher Yadier Molina of the Cardinals left in the ninth with lower back spasms. He exited after trying to get away from a pitch from Marmol that nearly hit him.
''It was more low back. I don't know what it was, it just tightened up on him,'' Matheny said. ''Trying to react at max speed doesn't help, either. Trainers were encouraged, thought it's something we'll be able to take a look at in the morning and adjust from there.''
St. Louis stranded 13 batters and missed several chances to take command of the game. James Russell struck out pinch-hitter Shane Robinson with runners on the corners to end the eighth, while Marmol got Tony Cruz to fly out with the go-ahead run on third to end the ninth. Cruz pinch-hit for Molina.
Wainwright is winless over his last five starts. He allowed four runs and six hits over seven innings. He hasn't lost in his last eight starts at Wrigley Field.
The Cubs need to win four of their last 10 games to avoid the third 100-loss season in franchise history and first since 1966.
''We came back. I just loved the way the guys battled the whole game,'' Cubs manager Dale Sveum said. ''Win or lose, the guys are battling and not making it easy on anybody.''
NOTES: Cardinals RHP Jake Westbrook (strained right oblique) was shut down just a few pitches into his bullpen session. He will be re-evaluated Sunday. RHP Lance Lynn will start in Westbrook's place Monday at Houston. ... Cardinals RHP Chris Carpenter felt ''good sore'' a day after his season debut Friday, according to Matheny. He is scheduled to pitch Wednesday in Houston. ... Barney's errorless streak at second base reached an NL-record 137 games, four short of the major league record set by Detroit's Placido Polanco in 2007.