Curtis Granderson, Tyler Heineman and Austin Dean hit late home runs and the Miami Marlins rallied against Zack Wheeler to beat the host Mets, 4-2, on Thursday night.

Wheeler, a potential free agent pitching perhaps for the last time with the Mets, hit a run-scoring single to break a scoreless tie in the seventh inning.

Wheeler (11-8) had allowed only two hits until Harold Ramirez led off the eighth with a double and Heineman connected with one out for his first major league home run, tying the game at 2-2.

Granderson, who played for the Mets from 2014-17 and still draws warm ovations at Citi Field, followed with his fourth pinch-hit homer of the season.