Amed Rosario, who had two of New York's four hits, began the winning rally with a two-out double off Mark Leiter Jr. (0-1) - the first hit for the Mets since the fourth inning. Jose Reyes walked and Nimmo drove Leiter's next pitch well over the wall in right-center for his first career walk-off RBIs.
It was New York's third game-ending homer in the last six days. Jose Bautista beat Tampa Bay with a grand slam last Friday, and Wilmer Flores connected Monday in the series opener against Philadelphia to help the Mets earn a four-game split.
In his final scheduled start before heading to the All-Star Game next Tuesday in Washington, deGrom scattered five hits and matched his longest outing of the season. He struck out seven and lowered his major league-leading ERA to 1.68.
Still, the right-hander has only five wins on the season. He's allowed just one earned run over his last 16 innings but has consistently been hurt by a lack of run support from an anemic New York offense all year.
This time, at least, the Mets didn't let deGrom's gem go to waste.
Robert Gsellman (6-2) pitched a scoreless inning for the win.
More AP baseball: https://apnews.com/tag/MLBbaseball