If not for some late heroics, the Marlins could have left Wrigley Field completely reeling. In the sixth inning, Alvarez sustained a left hip strain. Miami was also on the verge of being swept.
"You could see early on with the way the wind was, it was going to be a tight game," Marlins manager Mike Redmond said. "They did a nice job pitching to us, but today we battled and found a way to win the ballgame."
It was an uphill climb all afternoon for the Marlins, who capped their 10th comeback of the season and improved to 33-30 on the season.
The Marlins, who started off the season dreadful on the road, are now 11-19 away from Marlins Park. They've won eight of their last 12.
Their overall play in three games at Wrigley Field, however, was disappointing.
"We played terrible, not on our game these whole three games," Stanton said. "In fact, we should have had all three of them. We just weren't on our game, very flat. Uncharacteristic."
After dropping the first two in Chicago, Miami took the series finale and improved to 3-2 on the road trip, which continues on Tuesday at Texas.
Steve Cishek worked a perfect ninth for his 14th save in 15 chances.
Twice the Marlins played catchup. The second time, they claimed the lead, scoring twice in the eighth off Pedro Strop. Christian Yelich walked to open the inning, and with one out, Stanton was hit by a pitch. Casey McGehee's single to center loaded the bases, and Garrett Jones' sacrifice fly tied the score at 3. On the play, Chris Coghlan's throwing error allowed Stanton and McGehee to advance. Stanton scored the go-ahead run on Strop's wild pitch.
Miami was able to halt Chicago's winning streak at five games.
"I think these guys should keep their heads up," Cubs manager Rick Renteria said. "They're very disappointed right now because we felt we were on the cusp of being able to have a perfect homestand. I think they were trying to do it. Alvarez is no easy pickins'. He has great stuff and you see him in person and see why he's so effective. We just couldn't get it finished."
The Cubs surrendered the lead in the seventh, but gained it back in their half of the inning when Luis Valbuena drew a bases-loaded walk with two outs. The inning started with Darwin Barney being clipped by an A.J. Ramos pitch. With two outs and the bases full, Mike Dunn walked Valbeuna after running the count full.
Alvarez's injury occurred while the Miami right-hander landed awkwardly while covering first base on Valbuena's sharp grounder to first in the sixth. Jones made a nice play to gather the grounder, but his underhand toss was high, causing Alvarez to make a leaping catch while on the run.
"I felt like I could still pitch, but for precautionary reasons, they took me out," Alvarez said.
Alvarez stretched, extending his leg back in an attempt to touch the base. Jones was charged with an error on the play. The Cubs had runners on first and third, because Starlin Castro had doubled with one out.
Alvarez attempted one warmup pitch and immediately was replaced by Dan Jennings.
Once Alvarez exited, so did his streak of 26 straight scoreless innings. Nate Schierholtz ripped a two-run triple to right off Jennings. Only one of the runs was earned. The Marlins avoided further damage when Coghlan bounced to second, and Ed Lucas threw home, starting a rundown in which Schierholtz was tagged out.
Although Alvarez got one out in the sixth before the two runs scored, his streak didn't reach 26 1/3 because the Cubs scored in the inning.
Alvarez's afternoon was done after 5 1/3 innings and 69 pitches, with 54 strikes. The 26-inning scoreless streak is third longest in team history, behind Luis Aquino (26 1/3, 1994) and Javier Vazquez (29, 2011).
"I felt fine," Alvarez said. "I felt all my pitches were working. My sinker, my changeup, my slider were working pretty well. Unfortunately, I got hurt and I had to be taken out of the game. I really wanted to keep on pitching and do what I can to help the team."