He’s never done it at any level. Not at Ward Melville. Not in the minor leagues. But boy, was Steven Matz close to pitching a no-hitter for the Mets on Sunday.

Matz threw 7 1⁄3 no-hit innings against the Padres before allowing a single to Alexei Ramirez that was just fair inside the first-base line.

The Long Island lefty was denied a chance at the second no-hitter in Mets history by a matter of inches. Matz immediately was removed from the game by manager Terry Collins and the Mets went on to a 5-1 victory before 26,612 at sweaty Citi Field.

“I’ll tell you what: Guys were rooting for him heavily in that dugout,” Collins said. “He was cruising pretty good.”

Matz (9-8) had allowed only a pair of walks when Ramirez lined an inside pitch just inside the first-base line with one out in the eighth. First-base umpire Carlos Torres jumped out of the way of the hard-hit ball before pointing toward second base.

Fair ball.

advertisement | advertise on newsday

Collins sprinted out of the dugout, but not to challenge the call. Balls that bounce in the infield before crossing a base are not reviewable under baseball’s replay rules. The call appeared to be correct, anyway.

No, Collins ran out to remove Matz, who had thrown 105 pitches. Collins has never gotten over allowing Johan Santana to throw 134 pitches in the only no-hitter in Mets history on June 1, 2012.

Santana made 10 more starts that season before going down with a shoulder injury. Despite several comeback attempts, he has not appeared in a major-league game since.

Mets videos

“If [Matz] got through the eighth inning,” Collins said, “I was going to let him start the ninth depending on what the eighth inning looked like. If he walked a couple of guys and got up there pretty high, I wasn’t going to visit the Johan Santana scenario again, I can tell you that.”

Matz, who is pitching with a bone spur in his elbow that might require surgery after the season, threw a career-high 120 pitches in his previous outing.

“I was really worried about . . . I really wanted to cut him back because of the 120 last time,” Collins said. “And I looked up there and saw 65 or 70 and I said, ‘Here we go again.’ ”

Of the possibility of being removed with a no-hitter, Matz said: “It really wasn’t on my mind. The only thing on my mind was just getting outs.”

Matz struck out eight. He was consistently in the mid-90s with his sinking fastball and gave the light-hitting Padres fits with his curve.

advertisement | advertise on newsday

“I would say this is probably the best game I’ve thrown in the big leagues so far,” Matz said. “My arm’s been feeling great. I have no complaints there.”

The Mets, who got solo home runs from Wilmer Flores in the second and Neil Walker in the fourth, put the game away with a three-run bottom of the eighth. Jose Reyes scored on a wild pitch and T.J. Rivera drove in the first two runs of his career with a two-out double.

The Mets won consecutive games for the first time since July 6-7. Winning the past two days with Jacob deGrom and Matz throwing bullets has the Mets feeling much better heading into a 10-game road trip that begins Monday at Arizona.

“I know how disappointed everybody is with the way things have happened, what’s occurred this summer,” Collins said. “But this is still a good team. Expectations are still high. We’re still the National League champions. That’s never going to go away. The future’s still here with deGrom and Matz and [Noah] Syndergaard and hopefully Matt Harvey.”

Things did not start auspiciously for Matz on the 96-degree afternoon. He walked the first batter of the game, Travis Jankowski, then was called for a balk when Jankowski took off for second and Matz awkwardly and belatedly threw to first.

advertisement | advertise on newsday

But Matz struck out the Padres’ best hitter, Wil Myers, and Jankowski was thrown out attempting to steal third by Rene Rivera for the second out. Padres manager Andy Green challenged the call; it was upheld after a 1:09 replay review. Matz struck out former Yankee Yangervis Solarte to end the inning.

The Mets took a 1-0 lead in the second when Flores hit his 12th homer of the season off Clayton Richard (0-2). They made it 2-0 when Walker hit his 21st leading off the fourth.

Matz struck out one in the second, one in the third and one in the fourth. Solarte ended the fourth with a line drive to the mound that Matz caught.

Matz pitched to the minimum 15 batters through the first five innings. He walked Derek Norris to lead off the sixth and nearly gave up a two-run home run one batter later when pinch hitter Christian Bethancourt launched a long drive to left. But it was foul all the way and Matz eventually struck out Bethancourt with a nasty breaking pitch.

With two outs and a runner on first, Jankowski bunted through the first pitch for a strike before grounding into an inning-ending forceout. Usually, bunting to attempt to break up a no-hitter is a baseball no-no.

Matz retired the Padres 1-2-3 in the seventh, with Jay Bruce making a nice running catch near the rightfield foul line for the second out.

Matz, who had walked in the fifth inning, came to bat with two outs in the bottom of the seventh to a standing ovation. He swung at the first pitch and grounded to short.

In the eighth, Matz struck out Jabari Blash on a 3-and-2 pitch for his final strikeout. He also crossed the 100-pitch barrier during the at-bat.

Ramirez singled on pitch No. 105 and Matz walked off to another ovation. The crowd let him know they appreciated what he did and what he almost had a chance to do.

“Oh, yeah, I wasn’t disappointed at all,” Matz said. “We were up 2-0 and this is about team wins in the big leagues. That’s real ly what our focus is.”