The Pirates' last trip to the playoffs ended with Atlanta's Sid Bream sliding home with the winning run in the bottom of the ninth inning of Game 7 of the 1992 NL championship series.
The Cubs tied it in the eighth off Mark Melancon (3-2).
Marte's 12th homer set off loud boos for Gregg (2-6), who was almost released last week after going on a rant to reporters when he thought he had lost the closer's job to Pedro Strop.
Walker homered against Jeff Samardzija in the first to give the Pirates a 1-0 lead, and Charlie Morton pitched three-hit ball over seven scoreless innings before the Cubs tied it against Melancon.
Brian Bogusevic led off the eighth with a single, his second hit, and moved up on a groundout by Darwin Barney. Then, after a wild pitch, he scored the tying run on a single by pinch-hitter Donnie Murphy.
That spoiled a terrific start for Morton, who struck out five and walked one.
Samardzija was almost as good, allowing one run and five hits over six innings. He struck out seven and walked four after going 0-1 with a 7.11 ERA in his previous four starts.
Samardzija's only blemish in this one came when Walker drove a 1-1 pitch out to left-center with one out in the first.
With the long ball, Walker matched a career high of 14 set last season. He has four homers in the past five games.
Samardzija settled down after that but got little support as the Cubs lost for the 10th time in 13 games. It was also the second straight day an opponent celebrated at Wrigley Field.
Atlanta clinched the NL East on Sunday, and this time, it was the Pirates' turn to party.
"That's what we need to do," Samardzija said. "I think we're getting there, but we need to get some things ironed out."