The Mets' Pete Alonso, right, is greeted by third-base coach...

The Mets' Pete Alonso, right, is greeted by third-base coach Gary DiSarcina after hitting a two-run home run during the ninth inning against the Padres on Tuesday in San Diego. Credit: AP/Gregory Bull

SAN DIEGO — Not often does a major-leaguer, never mind a rookie, declare a random game in early May against a non-division opponent a must-win. But that’s what Pete Alonso did Monday night at Petco Park, announcing after another Mets loss: “We got to get them tomorrow. It’s a must. We need to win tomorrow.”

Alonso spoke — boldly, confidently, maybe dangerously — and then backed it up. His two-run home run in the top of the ninth lifted the Mets to a 7-6 victory Tuesday (after trailing 5-2 through six) against the Padres, their first win on a road trip that ends Wednesday. Edwin Diaz loaded the bases with one out in the ninth, but escaped, allowing one run.

“Today was a really big character test for us,” said Alonso, who went 3-for-5 with four RBIs. “This was a really, really good team win.”

Alonso’s latest feat one was another moonshot, the sort of blast he has quickly become known for. It bounced off the third deck of the Western Metal Supply Co. building in leftfield — three stories above the landing spot of Bartolo Colon’s majestic shot three years ago to the day — and traveled an estimated 449 feet. It came off Alonso’s bat at 114.7 mph.

He enjoyed this one, too. On Monday, Alonso was 0-for-4 with three strikeouts, including two punchouts against Padres rookie Chris Paddack, with whom Alonso has randomly developed a personal rivalry. Paddack said during the weekend that he wanted to beat Alonso, who was NL rookie of the month over Paddack in April, and Alonso said the trash talk “didn’t sit well.” Paddack won their one-on-one duel as the Padres beat the Mets, which left Alonso flustered.

And so Alonso’s home-run trot began with a bat flip — accidentally tossed over catcher Francisco Mejia and plate umpire Bill Miller because it stuck to his hand — and slow walk toward first as he watched the ball soar.

“I blacked out for a little bit,” Alonso said. “I just remember touching home. I don’t even remember rounding the bases.”

Said manager Mickey Callaway: “He’s a dangerous hitter. You feel like something dangerous is going to happen.”

When he took the field for the bottom of the ninth, Alonso crossed paths with Padres shortstop Manny Machado, who asked him, “Is that all you got?”

“He kinda gave me a wink and a smile after he said it,” Alonso relayed.

The homer was big in the figurative sense, too. It helped the Mets snap a four-game losing streak and capped what qualifies as an offensive outburst. The Mets’ seven runs Tuesday matched their May total (six games) to begin the day.

“That’s the team we have, that’s the offense we have,” Callaway said. “As long as we keep on creating opportunities, we’re going to score some runs. It was nice to see that again tonight.”

It was almost for naught as Diaz nearly blew it in the ninth, allowing a run for the third time in his past four appearances (tripling his ERA from 0.84 to 2.45). With the bases loaded, he got Eric Hosmer to strike out looking at a 97-mph fastball that nicked the inside edge of the plate. Hosmer disagreed with the call.

Hunter Renfroe grounded out to shortstop Amed Rosario, who made his NL-leading 10th error of the season earlier in the night but smoothly handled this routine grounder, to end it.

“[Diaz] made some big pitches when it mattered,” Callaway said. “He got the job done. That’s all you can ask of your closer.”

Noah Syndergaard’s brilliance from last week — when he tossed a shutout and homered in the same game — was gone. The Padres smacked him around for five runs (four earned) and nine hits (plus a walk) and struck out just five times in six innings. Syndergaard said he is still having trouble gripping his slider.

The Padres’ Cal Quantrill allowed two runs and seven hits in 4 1/3 innings.

Highlighting the Mets’ three-run rally in the seventh: a game-tying double from Brandon Nimmo, snapping his 0-for-28 streak that began April 28.

Amid the Mets’ two-run rally in the first was a milestone for Robinson Cano: a double for his 2,500th career hit. It came off Quantrill, the son of Paul Quantrill, who was briefly Cano’s teammate on the 2005 Yankees.

Cano is the 101st big-leaguer to collect that many hits. The only active players with more are Albert Pujols (3,106) and Miguel Cabrera (2,714).

“It means a lot, because you look back and it’s something you dream of as a kid, to play the game and be successful,” Cano said. “But it was great to get a win after losing the last four games.”

Newsday LogoSUBSCRIBEUnlimited Digital AccessOnly 25¢for 5 months
ACT NOWSALE ENDS SOON | CANCEL ANYTIME