CHICAGO (AP) With an early game Saturday, manager Joe Maddon figured the only way he would find out if the Chicago Cubs clinched a playoff spot was if he got up to go to the bathroom.
Well, they are in. And if Maddon slept through the night, he woke up to a nice surprise.
The sign outside Wrigley Field lit up with ''Cubs Clinch Postseason Berth'' after it became official late Friday night. Fans gathered around to take pictures and mark Chicago's return for the first time since 2008.
More from FoxSports
The Cubs could have wrapped it up Friday afternoon with a win over the Pittsburgh Pirates, except Gerrit Cole outpitched Jon Lester and a late rally fell short in a 3-2 loss.
San Francisco then lost to Oakland 5-4, and that assured Chicago of at least an NL wild-card spot.
With a 12:05 p.m. start Saturday, Maddon said he would check the West Coast score, maybe, ''probably when I get up to go to the bathroom at night.''
The road back to the playoffs was a long one for the Cubs, who endured five straight losing seasons and a painful top-to-bottom overhaul under Theo Epstein.
He began loading up the minor league system almost as soon as he was hired in October 2011, and it paid off in a big way.
Young players started to make their way to the majors last season. The Cubs then made it clear they were serious about winning when they hired Maddon and signed Lester in the offseason.
Kris Bryant, who had two hits and scored Friday, debuted this season, as did Kyle Schwarber. And both players made big impacts.
''We'll hopefully celebrate tomorrow and have a good time,'' said Lester, who like Maddon was not planning to stay up. ''These guys have never experienced this. We'll enjoy it.''
On Friday, the Pirates hung on for their seventh straight win and increased their lead for the NL's top wild card to 4 1/2 games over the Cubs.
Cole (18-8) and Lester (10-12) each lasted seven innings, and Mark Melancon held on in the ninth for his major league-leading 51st save in 53 chances.
Chris Denorfia led off the ninth with a double and scored on Starlin Castro's one-out triple to right as the Cubs closed within a run and excited the crowd of 40,432.
Melancon then struck out Jorge Soler and Javier Baez on knuckle curves in the dirt.
Cole's 18 wins are the most for a Pirates pitcher since John Smiley went 20-8 in 1991. He gave up two runs and five hits, struck out eight and walked two while improving to 7-1 in nine starts against Chicago.
He also drove in the game's first run with a single in the third.
Michael Morse put Pittsburgh ahead 2-1 with an RBI single off Lester in the seventh. The Pirates added a run in the eighth against Pedro Strop when Jordy Mercer reached on a wild pitch as he struck out leading off and scored from third on a grounder by Starling Marte.
Lester allowed two runs and five hits.
The Cubs had runners on first and second in the eighth, but Tony Watson struck out Anthony Rizzo to end the threat.
Cole gave the Pirates a 1-0 lead in the third with a single past a diving shortstop Addison Russell after Jordy Mercer doubled.
The Cubs tied it in the fourth when Bryant led off with a single and scored from third on a force by Addison Russell.
It stayed that way until the seventh, when former Cub Aramis Ramirez led off with a double and scored on Morse's one-out single. Morse, who was running on the pitch, then got doubled off on Josh Harrison's pop fly to first to end the inning.
NO ILL INTENTION
Coghlan insisted he wasn't trying to injure Jung Ho Kang with a takeout slide at Pittsburgh last week that left the Pirates shortstop with a broken left leg and torn knee ligament.
''I hate that he misses the whole year and it's a significant injury and a big blow to them,'' Coghlan said. ''But I think those guys over there understand the way I play and it wasn't a dirty play.''
Pirates: RF Gregory Polanco (knee) and 3B Ramirez (groin) were back in the lineup after being held out Thursday against the Colorado Rockies.
Pirates: LHP Francisco Liriano (11-7, 3.41 ERA), coming off a win over Clayton Kershaw and the Los Angeles Dodgers, looks to stay on a roll for Pittsburgh. He is 7-1 in his past 15 starts, with the Pirates winning all but one of those games.
Cubs: With a 5.77 ERA over his last 11 starts, RHP Jason Hammel (9-6, 3.79) looks to break out of his slump.