NEW YORK — Pete Alonso homered twice to become the second player in Mets history with four 30-homer seasons, leading retooling New York to a 5-1 victory over the Washington Nationals on Friday night.

The Mets won their second straight a little less than 24 hours after sending closer David Robertson to Miami for two rookie-ball prospects — signifying a trade deadline selloff. New York opened the season with a record $343 million payroll but entered Friday seven games out of a wild-card spot.

“Disappointed — I mean, obviously, we put ourselves in this position. We haven’t played well enough as a team,” said Max Scherzer, who allowed six hits and struck out seven in seven solid innings but has an ERA of 4.01, which would be his highest since 2011. “I’ve had a hand in that for why we’re in the position that we’re at. Can’t get mad at anybody but yourself, but it stinks.”

Scherzer, who has a player option worth $43.3 million for next season, said he expected to have discussions with owner Mets owner Steve Cohen and the team’s front office before Tuesday’s trade deadline.

The Baltimore Banner thanks its sponsors. Become one.

“You have to talk to the brass — you have to understand what they see, what they’re going to do,” Scherzer said. “That’s the best I can tell you. I told you I wasn’t going to comment on this until Steve was going to sell. We traded Robertson; now we need to have a conversation.”

Alonso hit a 453-foot, two-out, three-run homer into the second deck in left field in the fifth inning off MacKenzie Gore (6-8), who opened the frame by walking the bottom two hitters in the Mets’ order, Brett Baty and Francisco Álvarez.

Alonso added a two-run, 423-foot homer to center in the seventh off Rico Garcia.

The second homer was the 30th of the season for Alonso, who joined Mike Piazza (1999-2002) as the only players with four 30-homer seasons for the Mets.

“I didn’t know that until earlier — that’s really cool; that’s really special,” Alonso said. “Awesome, but I just want to help the team win.”

The Baltimore Banner thanks its sponsors. Become one.

The only season in which Alonso has not reached 30 homers was during the pandemic-shortened 2020 campaign, when he hit 16 homers in 57 games.

The two-homer game was the second in the last four games for Alonso, who had just four homers in 30 games from June 7 through July 23 — a span that included a stint on the injured list with a bruised left wrist.

Alonso also made an impressive play to end the eighth, when he dove between first and second bases to field a grounder by Keibert Ruiz and threw from a sitting position to Adam Ottavino covering first.

“When you get it going again, somebody’s going to pay — you always feel that with Pete,” Mets manager Buck Showalter said. “‘OK, if I’m struggling, you’re going to feel my pains somewhere along the way.’”

Scherzer (9-4) carried a shutout into the seventh, when Luis García hit a leadoff homer. García finished with three hits — including two off Scherzer, against whom he is hitting .545 (6-for-11).

The Baltimore Banner thanks its sponsors. Become one.

Ottavino pitched the eighth, and Brooks Raley worked the ninth.

Gore gave up three runs in five innings. He tied a season high by walking four batters for the first time since May 23.

“When he’s throwing strikes and he’s getting ahead, he’s really good,” Nationals manager Dave Martinez said. “Tonight, he was really good until he walked those two guys.”