Noah Syndergaard hits a two-run homer during a four-run fifth...

Noah Syndergaard hits a two-run homer during a four-run fifth inning at Chase Field in Phoenix on Tuesday night, Aug. 16, 2016. It was the Mets pitcher's third home run of the season. Credit: Getty Images / Norm Hall

PHOENIX — The Mets finally accomplished what most everyone else in the National League this season had already done. By picking on the shakiest pitching staff in the league, the Mets beat the Diamondbacks, 7-5, last night, ending what had been a four-game losing streak to one of the worst teams in baseball.

The Mets (60-59) remain in the chase for a wild-card spot, just three games off the pace. The Diamondbacks (49-69) have long turned the page to next season. Until last night, it was easy to confuse those roles.

Fireballing righthander Noah Syndergaard set the tone with his bat, bashing a go-ahead two-run shot in the fifth inning that seemed to jolt an offense to life. And the bullpen turned away a late rally — with closer Jeurys Familia nailing down his 40th save of the season — to cement the Mets’ first win of the season against the D-backs.

“It’s an awesome feeling,” Syndergaard said of his go-ahead homer. “I watched it a little bit on that one.”

The Mets had entered the fifth down 1-0 on Yasmany Tomas’ 23rd homer of the season, a solo shot that hugged the leftfield line. But after Rene Rivera’s long sacrifice fly tied the game, Syndergaard put the Mets ahead for good, lining his third homer of the season about six rows up the rightfield stands.

The Mets scored four runs in the fifth before tacking on three more in the sixth, chasing Diamondbacks righty Braden Shipley, who had tossed seven shutout innings against the Mets on Thursday at Citi Field.

In the rematch, the Mets pounced on Shipley for seven runs (six earned) and 10 hits in five-plus innings. The most emphatic of them all came from Syndergaard.

Perhaps Shipley did not pay attention May 11, when Syndergaard hit a pair of homers against the Dodgers. Or maybe he let his guard down. After all, Syndergaard had hit just .107 since his outburst at Chavez Ravine. Faced with a full count, Shipley tossed a 91-mph cookie down the middle of the plate. Syndergaard unleashed his quick lefthanded swing, then watched the ball take off. Shipley looked the other way in disgust.

Soon, Syndergaard’s long blond hair was bouncing beneath his batting helmet as he rounded the bases. His three homers this season equaled a franchise record with Walt Terrell (1982) and Tom Seaver (1972).

The Mets finished with six extra-base hits, equaling their total for the last five games combined. It was their most in a game since recording eight in a victory against the Nationals on July 7.

“It’s nice that we hit some doubles for a change tonight,” Collins said. “We have not swung the bats very well against them and tonight we got some opportunities.”

Kelly Johnson homered. Alejandro De Aza hit a pair of doubles. And T.J. Rivera, recently promoted from Triple-A Las Vegas, collected four hits.

But at third base, he has three errors in his last two games. And it was his shoddy glovework in the sixth that got Syndergaard chased.

Rivera made a wide throw to pull James Loney off the bag, then let another grounder pop out of his glove, thus extending an inning in which the Diamondbacks scored three runs.

The last straw came when the speedy Jean Segura hit a grounder to third. Rivera made a weak throw that might have still been on time had Loney stretched for it. Instead, replay showed Segura legged out a hit.

The misplay sent Syndergaard to the showers after allowing four runs (two earned) in 5 2⁄3 innings, though his line didn’t capture what was a strong night. His last few starts had been marked by high pitch counts and inconsistency. But until his defense failed him, Syndergaard showed a renewed sense of command.

“These past five days, I’ve spent a lot of time on the mound in between starts trying to get back on track,” said Syndergaard (10-7), the first time in his big-league career he’s reached a double-digit win total.

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