Darnell McDonald hit a three-run homer and the Chicago Cubs held on Wednesday to win their last home game of the season 4-2 over the Pittsburgh Pirates.
The Pirates kept their one-game lead for the top NL wild-card spot over the Reds, who lost to the Mets. They fell three games behind the Cardinals in the NL Central with just three to play because St. Louis beat Washington.
Jake Arrieta (4-2) pitched six innings for the win, giving up a run, four hits and two walks with one strikeout.
Kevin Gregg gave up an RBI triple to Jose Tabata in the ninth but struck out two in a row to earn his 33rd save of the season.
McDonald had three hits, all off Francisco Liriano, who was trying to become the first Pirates pitcher to win more than 16 games in 22 years. The other two hits were doubles.
"Mac had a heck of a day off one of the best left-handed pitchers in the game," said Cubs manager Dale Sveum. "He's done a great job for us since he's been here. He really filled a need and a spot for us and has done a great job in the outfield."
The Cubs went 31-50 at Wrigley Field this season. They snapped a three-game losing streak and avoided being swept by the Pirates at home for the first time since May 5-7, 2000.
The Pirates, off to the playoffs for the first time since 1992, will finish their season at Cincinnati this weekend.
"We'll try to win a couple, and go from there," Pirates center fielder Andrew McCutchen said of the team's final series before starting the postseason. "I remember at the beginning of the season, no one gave us a chance, and now look where we are. I'm just happy we can be there."
Liriano (16-8) struck out eight but took the loss. He gave up four runs, eight hits and a walk in five-plus innings. John Smiley was the last Pirates pitcher to win more than 16 games when he went 20-8 in 1991.
McDonald's first home run as a Cub gave Chicago a 4-1 lead in the sixth inning and knocked Liriano out of the game. The homer also scored Donnie Murphy, who led off the inning with a single, and Junior Lake, who walked.
Justin Grimm struck out two in a perfect seventh inning for the Cubs and Pedro Strop worked around a Justin Morneau single in a scoreless eighth.
Tabata's triple in the ninth scored pinch-runner Felix Pie but Gregg fanned Marlon Byrd and Starling Marte to end the game.
Earlier, the Cubs took a 1-0 lead in the first inning after Darwin Barney doubled with one out and scored on Anthony Rizzo's single. The Pirates loaded the bases with two outs in the third and Arrieta walked Morneau to force home a run.