Todd Frazier of the Mets celebrates with teammate Carlos Gomez...

Todd Frazier of the Mets celebrates with teammate Carlos Gomez after scoring on a single by J.D. Davis during the eighth inning against the Diamondbacks at Chase Field on Friday in Phoenix. Credit: Getty Images/Norm Hall

PHOENIX — Decidedly unclutch for most of Friday night, the Mets used a change in luck to change the game, rallying in the eighth for a 5-4 win over the Diamondbacks.

The Mets entered the penultimate inning just 2-for-12 with runners in scoring position, out-hitting Arizona except for when it mattered most. Then, with two outs, came the good fortune: a single by Todd Frazier on an off-balance swing, a soft single by Adeiny Hechavarria poked down the rightfield line, and an infield single by J.D. Davis that looked like a routine inning-ending groundout until reliever Matt Andriese reached for it with his glove and deflected it. That tied the score at 4-4.

Pinch hitter Carlos Gomez put the Mets ahead for good with an RBI double ripped barely fair down the third-base line.

“Sometimes just touching the ball goes a long way,” manager Mickey Callaway said. “We are unbelievable at coming back. You continue to stress let’s add on, let’s add on, let’s step on some people’s throats. But man, these guys fight. They never quit.”

Because plate umpire Jim Wolf had left the game in the second after Frazier’s foul tip hit his mask (which fell off his face), there was no third-base umpire available to rule fair or foul on Gomez’s hot grounder, and because the ballboy down the leftfield line thought it was foul, he picked up a ball that was in play.

That took a while to sort out. Davis had to stop at third and Gomez at second because the ballboy on the field — not a fan in the stands — touched the ball, making it an automatic ground-rule double and preventing the umpires from using their judgment to place the runners, crew chief Sam Holbrook said. The fair/foul call could not be reviewed, either. “The ball hit the ground before it passed the bag,” Holbrook told a pool reporter. “So that makes it non-reviewable no matter what.”

Those conclusions required at least three conversations: the umpires with Arizona manager Torey Lovullo, the umpires with Callaway and the umpires with replay headquarters in New York City. After several minutes of uncertainty, the call was upheld.

“I put a good swing on the ball and just run,” Gomez said. “I stop running when the umpires or [a coach] tells me fair or foul. That late in the game, you need to just run and wait for a call.”

Callaway opted for an unusual late-inning combo to finish it off. Seth Lugo, on his first day back from the injured list, pitched a scoreless eighth; Gomez’s misplay of a fly ball into a one-out triple got him in trouble, but he induced two pop-ups to escape the jam. Robert Gsellman, filling in for Edwin Diaz (rest), tossed the ninth for the save, his first of the season. Gsellman snapped a streak of four consecutive appearances in which he allowed at least one run.

For the Mets (28-29), that made a winner out of Zack Wheeler (4.68 ERA), who allowed four runs in seven innings. He cruised until the sixth, when Ketel Marte and Christian Walker homered. The former was a fly ball to right, the latter a scorched line drive — 110.4 mph, 447 feet — to left.

“I don’t even know who hit it, but the second home run that inning, he hit a good pitch,” Wheeler said. “It was a fastball at the knees on the black, and he just turned on it.”

In his first major-league start, Diamondbacks righthander Jon Duplantier, 24, allowed three runs in five innings. He stumbled only in the second, when Frazier (RBI single) and Hechavarria (two-run double off the centerfield wall) accounted for the only runs against him. Duplantier retired 12 of his next 14 batters to finish his outing.

“The one thing that we have to do a better job of is when we get ahead, we have to continue to add on,” Callaway said. “We’ve done it a couple times, but we have to do that consistently. We can’t let teams hang around and all of a sudden a homer or two puts them where they want to be.”

SUBSCRIBE

Unlimited Digital AccessOnly 25¢for 6 months

ACT NOWSALE ENDS SOON | CANCEL ANYTIME