That inning rescued what to that point had been an ugly day, starting with the unsurprising announcement that outfielder Michael Conforto had been placed on the 10-day disabled list with a bone bruise on his left hand.

Then, Zack Wheeler, in his first start since he came off the disabled list with biceps tendinitis, was lifted from the game after coming apart in the fourth inning. He followed an error at third base by Rivera with two walks and an error of his own — dropping the relay on what should have been an inning-ending double play — that allowed two runs.

There were other gaffes as well. Jose Reyes doubled in his first two at-bats, but nullified both with base-running mistakes. The first time, he was picked off by Phillies starter Jeremy Hellickson. The second time, he broke for third on an infield grounder and was easily thrown out. That mistake cost the Mets a run when pinch-hitter Brandon Nimmo doubled off the wall in right.

Lucas Duda gave the Mets a 3-2 lead with a solo homer in the fourth, but the Phillies tied the game in the fifth on an double by Joseph. And when Joseph homered two innings later, the stage seemed set for a disastrous loss.

But the Mets put a couple of hits on the board, and then Cabrera put one over the fence.

Cabrera’s home run did not close the book on the game. There was a 57-minute rain delay with two outs in the eighth inning, forcing Collins to use Addison Reed for a four-out save, and some anxious moments in the ninth when Aaron Altherr narrowly missed tying the game with a drive off the wall in right that became a leadoff double.

Afterward, bedecked in the regalia of the Mets’ player of the game — a plastic crown and a blue-and-orange boxing robe — Cabrera declined to revisit the discontent he expressed a week ago when he learned that the shortstop job would belong to Reyes.

“I’m not going to talk about that anymore,” he said. “I’m really happy here right now. We trust everybody here. I’m just coming every day to get better and help the team to win.”

Collins said he had faith that Cabrera would settle in at second.

“I’ll tell you, if we get him hot, we’re going to have a good finish,” Collins said.