ST. LOUIS (AP) -- St. Louis' bullpen stumbled, and the Cardinals still inched closer to the NL Central title.
Andrew Miller and Ryan Helsley were hit hard during an 8-2 loss to the Chicago Cubs on Friday night, but the Cardinals' magic number for clinching the division dropped to two.
Miller (5-6), Helsley and Giovanny Gallegos allowed each of Chicago's runs after Dakota Hudson struck out 10 in five scoreless innings.
The Cardinals (90-70) lost their third consecutive game after winning six in a row. But their magic number for securing their first division title since 2015 was sliced to two when second-place Milwaukee lost 11-7 at Colorado.
Ian Happ and Robel Garcia homered for Chicago (83-77), which had lost nine in a row. The Cubs were swept in a four-game series against the Cardinals last weekend.
Miller knew what was on the line when he took the mound in the seventh.
''These aren't playoff games, but they're as close as you can get without being there,'' Miller said. ''It does change pretty quick and you've got to be ready for it. It's frustrating, I didn't do my job today but (I've got to) be ready to go tomorrow.''
Cubs manager Joe Maddon celebrated by playing a video during his postgame press conference of Bette Midler singing ''Rochelle, Rochelle'' from a ''Seinfeld'' episode in the '90s. He inserted Robel Garcia's first name as he sang along in his office.
''This is something I've wanted to do for a while,'' Maddon said. ''The big blow tonight, the big blow came out of our second baseman and this explains it better than I possibly could.''
Alec Mills struck out nine while pitching five innings of one-run ball. But the right-hander left with a no-decision because Chicago was unable to put anything together against Hudson.
St. Louis jumped in front on Matt Carpenter's 14th homer in the fourth, but Happ tied it at 1 when he led off the sixth with his ninth homer off Gallegos.
The Cubs then went ahead to stay with seven more in the seventh. Happ hit a tiebreaking RBI double off Miller, and Wilson Contreras made it 3-1 when he scored on a wild pitch.
After Victor Caratini was hit by a pitch, Miller was replaced by Helsley. Nico Hoerner then hit an RBI single, Garcia connected for a three-run shot and Ben Zobrist singled in Tony Kemp before Genesis Cabrera got the final out of the inning.
Garcia stopped a 0-for-14 slide with his first homer since July 22. Happ finished with three hits and two RBIs.
Brad Wieck (2-2) got one out for the win.
Miller also struggled in his previous appearance, allowing a tying homer to Ildemaro Vargas in the Cardinals' 19-inning loss at Arizona on Tuesday.
''We had it lined up the way we wanted trying to bring home a one-run game,'' Cardinals manager Mike Shildt said.
Mills got some help from center fielder Albert Almora Jr., who made two big defensive plays against Yadier Molina.
Almora robbed Molina of a two-run double in the first and took a homer away from the catcher in the fourth, climbing over the wall. Almora pulled the ball out of his glove to show the umpires and the stunned crowd he had made the catch.
''For the homer, I was dealing with cramps even before the game but I forced through it,'' Almora said. ''I don't know man, everything slows down and I was able to make a play. I was excited.''
Cardinals rookie Tommy Edman had three hits to extend his hitting streak to nine games. Edman also picked up his 15th steal.
NO LOSS FOR YOU
The Cubs haven't lost 10 games in a row since the 2012 season, when they lost 12 straight from May 15-27, 2012.
NEARING THE END?
With rumors swirling about Maddon's future with the Cubs, several players made a point to have private conversations with the manager over the past few days.
''You know what? I don't think I've ever wanted to participate in the seminary, but I sometimes feel like 'Father Joe.''' Maddon said. ''They read, they see. So, I've had some really interesting, insightful and in-depth conversations.''
Cubs: OF Nicholas Castellanos (right groin tightness) was scratched. Castellanos got hurt during a pregame routine that happened before the team took the field. He is day to day.
Cardinals: 2B Kolten Wong (strained left hamstring) remained out of the starting lineup for the fifth straight game. Wong said he has been going through baseball activities the last two days. ''I pushed it pretty good today,'' Wong said. ''I think tomorrow we'll see how it reacts and it will be a big indication of if I can get out there.'' ... RHP Michael Wacha has a shoulder strain and general manager Michael Girsch said he's not going to throw for the next few days. ''Probably into the middle of next week or so,'' Girsch said. ''Then we'll see.''
Left-hander Cole Hamels (7-7, 3.92 ERA) pitches for Chicago in what might be his final game with the Cubs. Hamels can become an unrestricted free agent at the end of the year. Right-hander Adam Wainwright (14-9, 3.98 ERA) goes for his sixth consecutive win for St. Louis.