Here was the ultimate vote of confidence Monday for the Mets: They finally won a game.

With Mickey Callaway told by GM Brodie Van Wagenen he would remain the team’s manager for the “foreseeable future,” the Mets got their act together for a night and snapped a five-game losing streak with a 5-3 victory over the Nationals at Citi Field.

The Mets (21-25) were swept three games by the awful Marlins over the weekend (including getting shut out consecutively to conclude the series), leading to speculation Van Wagenen would fire Callaway. But Callaway’s second life is off to a good start, thanks to a solid night offensively and strong bullpen work.

“Things haven’t been going our way, but we broke a really bad slump and I think things are going to get better now,” said Amed Rosario, who homered against Patrick Corbin in the first inning.

Pete Alonso also hit a blast in the inning.

“You have trouble scoring runs for a couple of days and you pop [homers] in the first and then you can breathe a little bit,” Callaway said.

Wilmer Font rebounded from an ugly outing against the Nationals in his last start by largely escaping trouble for four innings in which he allowed two earned runs on three hits and four walks. Drew Gagnon was originally Callaway’s choice to start, but the manager changed course when Seth Lugo’s barking shoulder forced him to the injured list.

Gagnon entered in the fifth and gave the Mets two scoreless innings. Jeurys Familia followed with 1 ¹/₃ innings in which he allowed a run and Robert Gsellman got two outs in the eighth before Edwin Diaz closed out the victory with a scoreless ninth for the save.

Dominic Smith had provided the Mets an insurance run in the eighth with a pinch-hit RBI single.

Font didn’t bend until the fourth, when Yan Gomes delivered an RBI single to pull the Nationals within 4-2 after Anthony Rendon had homered leading off the inning.

Corbin walked Rosario and Wilson Ramos in the third inning, leading to two runs that gave the Mets a 4-0 lead. Todd Frazier’s second hit of the game, an RBI single, brought in the inning’s first run before Carlos Gomez launched a double to score Ramos.

Alonso’s blast was his 15th of the season, tying Ron Swoboda’s franchise rookie record for homers in the first half of the season.

Corbin lasted five innings and allowed four earned runs on six hits with seven strikeouts and three walks. Last week at Nationals Park he limited the Mets to one run over eight innings.

“It’s a new week and to get that first win after a prolonged slump on the road is awesome,” Frazier said.