The Mets celebrate on the field after the final out...

The Mets celebrate on the field after the final out against the Washington Nationals on Monday at Nationals Park in Washington. Credit: AP / Pablo Martinez Monsivais

WASHINGTON — The Mets, bad on Sunday last year and last week, waited until it was Monday to win this one.

Yoenis Cespedes lined the game-deciding single in the top of the 12th inning as the clock struck midnight, lifting the Mets to a 6-5 win over the Nationals. The victory was their fifth in a row and completed their first three-game sweep of Washington since September 2015.

At 7-1, the Mets have the best record in the National League. This time they proved resilient in a generally messy game that included three errors and a lot of Nationals baserunners (13 hits, seven walks, one hit batsman).

“That’s big time,” said Seth Lugo, who tossed three scoreless innings. “We’re having a lot of fun in here, and to keep that energy going, that’s big for us.”

Said Matt Harvey: “The way we pulled out the win today and kept battling and kept fighting, it shows a lot about this team and what we’re about. I think it’s sending a message not only to the guys across the locker room here but all of baseball.”

Jacob Rhame, a game after recording his first major-league hold, pitched a scoreless bottom of the 12th for his first major-league save. Adrian Gonzalez scooped Todd Frazier’s low throw across the diamond to secure the final out.

With the temperature dipping to 41 degrees on a windy night, Frazier said he couldn’t feel his hands very well. “My warmers in my pocket weren’t warm anymore,” he said.

Pinch hitter Juan Lagares started the winning rally with a single to center. After Amed Rosario moved him to second with a sacrifice bunt, the Nationals intentionally walked Michael Conforto. Cespedes, who had been 0-for-5 with three strikeouts and has been fighting a fever, singled to center.

Lugo and the Mets nearly lost it in the ninth, when Bryce Harper led off with a walk and reached third with one out. The Mets issued two intentional walks to load the bases — Harper’s run being the only one that mattered — and Lugo struck out Michael A. Taylor and Pedro Severino on six pitches.

All of the Mets’ regulation runs scored with two outs. In the third, three straight walks loaded the bases for Gonzalez, who hit a grand slam to right for a 4-2 lead. It was his first extra-base hit since his Opening Day double, a span of 21 plate appearances. Asdrubal Cabrera also had his first homer, a shot to right in the fifth.

Harvey allowed four runs, nine hits, one walk and a lot of hard contact. He struck out two and threw 85 pitches (57 strikes). He hasn’t pitched more than five innings since May (10 starts).

“Not very good. Actually, pretty poor,” he said. “If I didn’t give up those last two runs, we would have gotten out of here a couple of hours ago, so that’s pretty disappointing.”

Harvey’s line was close to looking much worse. In the fourth, he helped the Nationals load the bases when, with two outs, he committed a fielding error on a grounder by pitcher Tanner Roark (five innings, five runs) and hit Adam Eaton with a pitch after getting ahead 0-and-2. Anthony Rendon turned on a slider and sent it to deep leftfield where Cespedes — seemingly battling the wind — caught it.

Harper (3-for-4, two walks) hit a two-run homer in the first. Severino (fourth-inning double) and Trea Turner (fifth-inning single) and Taylor (seventh-inning single) added RBI hits. Taylor’s hit tagged Robert Gsellman, who pitched two rocky innings, with the Mets’ first blown save.

Roark also struggled, but with a higher pitch count (100 in five innings) and more runs allowed (five). The Mets had five hits and four walks against him and struck out nine times.

The Mets went 8-19 on Sundays in 2017, a curious trend that continued with their loss April 1 — still their only loss.

“From spring training, starting with [manager Mickey Callaway] and working all the way down, it’s been such an unbelievable clubhouse,” Harvey said. “It’s nice to come in here and have fun with everybody once again. It’s been a long time since that’s happened.”

Newsday LogoDON'T MISS THIS LIMITED-TIME OFFER1 5 months for only $1Save on Unlimited Digital Access