CHICAGO -- Donnie Murphy's go-ahead home run capped a four-run seventh as the Chicago Cubs beat the Miami Marlins 9-7 and to salvage the finale of a three-game series Wednesday afternoon.
Murphy's ninth home run drove in Dioner Navarro, who had singled home a pair of runs earlier in the inning.
The victory snapped a two-game Cubs skid as Carlos Villanueva (4-8) got the win and Kevin Gregg collected his 29th save.
Marlins reliever Ryan Webb (2-6) took the loss as Miami's three-game winning streak was halted.
Starlin Castro singled home pinch-hitter Brian Bogusevic in the eighth for a 9-7 edge.
Adeiny Hechavarria clubbed a sixth inning grand slam home run for a 6-3 lead, but the Marlins couldn't hold it.
Cubs starter Jeff Samardzija gave up the homer but had no decision. He had a strong effort under way until then, eventually giving up six earned runs on nine hits, while walking two and striking out nine.
Marlins starter Brian Flynn worked four full innings in his Major League debut, allowing three earned runs on six hits. He walked three and struck out two.
Hechavarria went 3-for-4 with four RBI while Giancarlo Stanton added two hits and scored twice for the Marlins. Navarro went 2-for-5 with three RBI, while Castro went 2-for-5 with two runs batted in for the Cubs.
Logan Morrison gave Miami a 2-0 lead in the second, clubbing a wind-aided home run that hit the back fence of the right field bleachers. Stanton was aboard after a leadoff infield single for Morrison's fifth homer of the season.
The Cubs replied with one run in the bottom of the inning. Junior Lake doubled and scored on Darnell McDonald's double to left.
The Cubs took a 3-2 lead in the third with solo home runs from Castro and Navarro.
Castro evened the score at 2-2 with his eighth home run -- a solo blast to right -- to lead off. Navarro then slammed his career-high 12th homer to center for the go-ahead run.
Flynn left the game in the fifth after allowing a leadoff double to Darwin Barney and a walk to Anthony Rizzo. Right-handed reliever Chris Hatcher got out of the inning unscathed.
Samardzija unraveled in the sixth when he loaded the bases and gave up the grand slam to Hechavarria on a 1-0 pitch, driving home Stanton, Justin Ruggiano and Morrison.
Hechavarria's first career grand slam came on May 5 at Philadelphia.
Ryan Sweeney trimmed the deficit to 6-4 in the sixth with a one-out homer with none aboard off reliever Arquimedes Caminero.
The Marlins got the run back in the seventh off reliever Villanueva when Donovan Solano tripled and scored when Navarro tried to catch him off base and threw to Murphy at third. The ball skipped down the line and Solano scored for a 7-4 lead.
Navarro's seventh inning single off Miami reliever A.J. Ramos drove home Barney and Rizzo with none out. Murphy scored Navarro with his home run to left on the first pitch off reliever Ryan Webb.
NOTES: The Marlins rank 13th in the NL with a .236 average with runners in scoring position but had shown improvement in their last three games, going 10-for-31 (.323) with RISP entering Wednesday. They were hitting .160 in the first five games of the current road trip. ... RHP Steve Cishek's Monday save was his 24th consecutive, the second-longest streak in club history and three behind Todd Jones (2005). ... RHP Jose Fernandez (10-6) takes the mound Friday when Miami opens a three-game home series against the Nationals at Marlins Park. ... The Cubs activated 37-year-old Korean RHP Chang-Yong Lim on Wednesday and designated RHP Michael Bowden for reassignment. Lim continues his recovery from Tommy John surgery and most recently pitched 11 relief outings with Triple-A Iowa with no record and a 0.79 ERA. ... Cubs LHP Chris Rusin (2-3) pitches Friday's series opener against Milwaukee. ... With appearances by RHP Alberto Cabrera and LHP Zach Rosscup on Tuesday, the Cubs have now used 52 players this season. That's one shy of the record 53 used in 2012.