Before Saturday, Steven Matz had only thrown a pitch in the eighth inning this season because of his bullpen cameo before the All-Star break.

The Mets did not need a fifth starter at the time, and Matz had been struggling, so he was the choice to briefly drop out of the rotation.

But the lefty saw the eighth inning again on Saturday, this time getting there on his own. And for the first time as a professional — he even pitched the ninth.

Matz cruised to his first career complete game and shutout, turning in an absolute gem to carry the Mets to a third straight win, 3-0, over the Pirates at Citi Field. He did not issue a single walk, he allowed just five hits and he struck out seven. Perhaps most impressively, he recorded the 27th and final out on his 99th pitch as the crowd of 39,944 stood and roared in appreciation.

“This was big for me today,” Matz said. “In the back of my mind, I really wanted to keep going out there.”

Throughout the night, Matz was economical with his pitches, needing more than 11 to finish an inning just twice. The only other time he completed seven innings this year, he did so on 101 pitches. He needed just 78 to get that far Saturday.

There was never any action in the bullpen until Edwin Diaz briefly got up in the ninth, but he was not needed. Matz finished the job by getting Josh Bell to ground out to shortstop, becoming the first Met to throw a shutout with fewer than 100 pitches since Johan Santana in 2012.

“He was just tremendous in every way,” said manager Mickey Callaway, who added Matz had about 110 pitches to work with. “To do it on 99 pitches is something else. That doesn’t happen too often.”

Matz’s shutout was the Mets’ third of the year, joining Noah Syndergaard and Jason Vargas.

The Mets (49-55) have now won four of their past five series. Their strong pitching lately — both from the rotation and the bullpen — has offered a reminder of what they hoped this year would be like. They may have already dug themselves too big a hole, making a few of Matz’s rotation mates trade candidates with the deadline nearing, but Saturday was a break from that.

“The trade deadline, you hear all those rumors and everything, but right now, we’re a unit, we’re together, and we’re still trying to make a push,” J.D. Davis said.

Davis, in the starting lineup against a right-hander because of Dominic Smith’s trip to the injured list with a stress reaction in his foot, provided insurance with a two-run homer he smoked to center field in the seventh inning to make it 3-0.

Michael Conforto had given Matz a lead to work with in the sixth after crushing a solo shot to right.

Matz was in command from the start. He did not allow a hit until the fourth inning, working aggressively and leaning on a slider Callaway called the best he’s ever seen from Matz. The Long Island native also used his sinking fastball to record each of his first five strikeouts, all of them looking.

The only time Matz might have had to break a sweat was in the sixth inning, when he put runners on the corners with one out. But he needed just one pitch to get out of it, forcing Melky Cabrera to ground into a 5-4-3 double play.

It gave Matz the chance to take the mound in the ninth for the first time in his life. He did not let it go to waste.

“It was really cool,” Matz said. “Honestly, this is what I try to do every game. So I finally did it.”