CHICAGO -- With the Miami Marlins holding a shaky one-run lead heading into the bottom of the ninth on Wednesday, it came down to closer A.J. Ramos to salvage a series finale.
The Chicago Cubs had scored single runs in the seventh and eighth, and Ramos got the last out in the eight. The sixth Marlins pitcher of the night, he came back out and delivered a scoreless final inning for his ninth save to preserve a 6-5 victory.
"Those are the situations I like to be in," he said. "I kind of stepped off (the mound) to feel the energy of the crowd. Even though it was negative energy toward me, I still feed off that, and I was able to get the job done."
Teammate JT Riddle went 2-for-4 with a go-ahead two-run single in the fourth inning as the Marlins grabbed one victory in the three-game series.
Right-hander Jose Urena (4-2) worked five innings for his third straight win as the Marlins (25-33) stopped a two-game slide. Urena allowed three runs on three hits while walking three and striking out five.
J.T. Realmuto homered in a three-run fourth inning, and Dee Gordon and Tyler Moore had two hits apiece for Miami.
"However it comes, we're just happy to have the win," Gordon said. "Honestly we needed to come out of here with at least one, and we battled the whole game for it."
Cubs right-hander John Lackey (4-6) took his third straight loss as Chicago (30-28) saw a five-game winning streak end. Lackey gave up five runs on seven hits, struck out six and hit one batter in six innings.
Chicago's Kyle Schwarber greeted Marlins reliever David Phelps with a leadoff solo homer in the seventh, cutting the Miami lead to 6-4.
Schwarber completed a 3-for-4 night as he doubled home Jon Jay off Marlins reliever Nick Wittgren with two outs in the eighth to make it 6-5.
The performance was some consolation for the Cubs after Schwarber's struggles in recent weeks.
"It's more reminiscent of what we've seen in the past," Chicago manager Joe Maddon said. "Great balance in his finish. Every time he's hit the ball well, he's just able to stand there because of his balance. ... A nice night for him, absolutely."
The Marlins grabbed an early lead for the second consecutive night. Gordon led off the game with a triple to left and scored on Christian Yelich's sacrifice fly.
The Cubs jumped ahead with a pair of third-inning runs. Schwarber doubled to left, Ian Happ walked and Anthony Rizzo doubled to right-center with two outs to bring them both home for a 2-1 lead.
The Marlins replied with three runs in the fourth. Realmuto forged a 2-2 tie with a one-out solo home run to left, his fifth of the season. Derek Dietrich then singled, Moore reached on a ground-rule double, and both came home when Riddle singled to center for a 4-2 lead.
In the fifth, Marcell Ozuna made it 5-2 with a two-out solo home run to left, his 15th of the season.
Happ got one run back for the Cubs, hitting a solo homer to left with two outs in the bottom of the fifth.
"I liked the way we played," Maddon said. "I thought we battled well, we had good at-bats. I thought we caught the ball on defense, Johnny (Lackey) had a tough night, but otherwise it was a pretty good game on our part."
NOTES: The Miami Herald reported Wednesday that Marlins' top-ranked prospect, LHP Braxton Garrett, has a partial tear of the ulnar collateral ligament in his left elbow and may require Tommy John surgery. ... The Marlins travel to Pittsburgh to open a four-game series Thursday, sending RHP Edinson Volquez (2-7, 3.79 ERA) against Pirates RHP Gerrit Cole (3-5, 4.27 ERA). Volquez no-hit Arizona on Saturday. ... Pittsburgh took two of three from Miami in an April 28-30 series. ... The Marlins are 87-98 all-time against the Pirates. ... The Cubs remain home to begin a four-game set against NL West-leading Colorado on Thursday as Rockies RHP Tyler Chatwood (5-7, 4.60 ERA) goes against Cubs LHP Jon Lester (3-3, 3.91 ERA). ... Cubs LHP Mike Montgomery has thrown 589 pitches in relief, the most of any reliever in the majors. ... The Cubs are batting .327 with the bases loaded but .209 in other situations with runners in scoring position.