Donnie Murphy hit the go-ahead two-run homer while Dioner Navarro homered and drove in three runs as host Chicago salvaged the finale of a three-game set against Miami.

The Cubs trailed by three runs entering the bottom of the seventh before Navarro singled home two runs and Murphy greeted Ryan Webb (2-6) with the decisive blast to left. Starlin Castro added a run-scoring double in the eighth.

Murphy’s homer made a winner out of Carlos Villanueva (4-8). Kevin Gregg worked around two walks in the ninth to record his 29th save in 34 opportunities.

Adeiny Hechavarria went 3-for-4 and hit a grand slam in the sixth to give Miami a 6-3 lead before Ryan Sweeney homered in the bottom of the inning to start the Chicago comeback. Castro also homered for the Cubs and Logan Morrison blasted a two-run home run for the Marlins.

Chicago starter Jeff Samardzija struck out nine in six innings but gave up six runs and nine hits. Miami’s Brian Flynn gave up three runs and six hits over four frames in his major-league debut.