Mets starting pitcher Steven Matz delivers a pitch against the...

Mets starting pitcher Steven Matz delivers a pitch against the Milwaukee Brewers during the first inning in an MLB baseball game at Citi Field on Sunday. Credit: Kathleen Malone-Van Dyke

The Mets showed up for work Sunday at Citi Field clinging to the National League’s bottom rung in ERA and errors.

They really needed to play a clean game and get a well-pitched start against Milwaukee after the duds thrown by Jacob deGrom and Noah Syndergaard in the first two games of the series. They got exactly that en route to a 5-2 win.

Steven Matz turned in a quality start, allowing two runs in seven innings. The bullpen was untouchable. There were no errors. And after the Brewers made one in the seventh, the Mets capitalized, scoring the tiebreaking run on J.D. Davis’ pinch-hit single.

So the Mets avoided the three-game sweep, snapped a three-game skid and rose back above .500 at 14-13.

“It was a quality team win,” said Pete Alonso, who rocked his first career triple and scored in the first and robbed Orlando Arcia of a single with a diving stop wide of first in the sixth. “We put five runs on the board. We had really good at-bats up and down the lineup. We played good defense. And the pitching was awesome today.

“I think we’ve got some of the best pitchers in the league .  .  .   When everything clicks, it’s going to be scary.”

This was the second straight time it clicked for Matz after his epic flop in Philadelphia in which he allowed eight runs and retired no one. This time the lefty from Long Island allowed five hits, walked none and struck out four while throwing to Wilson Ramos. Matz is 3-1 and owns a 3.68 ERA through six starts.

“I feel really comfortable,” he said. “I have a lot of confidence out there. It’s been good to work with Wilson. We seem to have a good rhythm together.”

After Matz allowed a tying two-out, two-run homer by Mike Moustakas in the top of the seventh, the Mets made him a winner with an unearned run in the bottom of the inning.

Ben Gamel dropped Amed Rosario’s one-out liner to right-center for a two-base error. Righty reliever Jacob Barnes (1-1) then intentionally walked pinch hitter Michael Conforto.

Mickey Callaway sent up lefthanded-hitting Dominic Smith to bat for Matz, Brewers manager Craig Counsell countered with lefty Alex Claudio and Callaway countered with the righthanded-hitting Davis, who lined a single to left to make it 3-2.

“When the players get hits, it works out great,” Callaway said about his moves.

Tomas Nido, fresh up from Syracuse to be the backup catcher after Travis d’Arnaud was designated for assignment, provided some insurance as a pinch hitter in the eighth, delivering a two-out, two-run double.

Seth Lugo had struck out the side in the top of the inning and Edwin Diaz finished it off with a 1-2-3 ninth for his eighth save in eight tries. The Mets are 12-0 when leading after six.

“Our bullpen has been getting the job done when we’re ahead,” Callaway said. “I think the parts that we’ve struggled with is when we get down a few, we’re not kind of keeping the other team there.”

The Mets were up a few early on, thanks to Todd Frazier’s RBI single in the first and Rosario’s RBI double in the second off lefthander Gio Gonzalez. He yielded only those runs in five innings in his first start since opting out of his contract with the Yankees and choosing the Brewers’ offer to enter their rotation right away over the Mets’ bid for him.

After Moustakas tied it, Davis promptly untied it, and the Mets improved to 5-6 at Citi Field.

“This is our house,” Davis said. “We should be defending it.”

Newsday LogoYour Island. Your Community. Your News.Digital AccessOnly 25¢for 5 months