Knicks guard Josh Hart reacts after scoring a basket against...

Knicks guard Josh Hart reacts after scoring a basket against the Dallas Mavericks in the first half of an NBA game at Madison Square Garden on Tuesday. Credit: Kathleen Malone-Van Dyke

Josh Hart and Karl-Anthony Towns etched their names into franchise history, a pair of triple-doubles carrying the Knicks to a much-needed win Tuesday night at Madison Square Garden.

The convincing 128-113 victory over the Dallas Mavericks was one-sided enough that they could watch from the bench in the end.

Hart set a Knicks single-season record for most triple-doubles. His 16 points, 12 rebounds and 11 assists was his ninth triple-double of the year, edging out Walt Frazier, who had eight in 1968-69.

And Towns joined Hart with 26 points, 12 rebounds and 11 assists to become the first pair of Knicks teammates to post triple-doubles in the same game in the team’s history.

And they then provided one more assist, handing the game ball to Kevin McCullar Jr., who made his NBA debut and scored his first points in the final minutes.

“For me that’s an easy decision,” Hart said. “That record is cool and a blessing, but at the end of the day that record’s going to get broken at some point. Hopefully, later rather than sooner. But that’s going to get broken. Getting your first NBA points, nobody can take that away from you. It’s important that he had that, got the game ball for that. That’s an easy decision for me.”

OG Anunoby scored 35 points, giving the Knicks a win with no new injuries, another night of healing and rest for the trio of sidelined rotation pieces and a step closer to the postseason.

The most important thing for the Knicks was the win. It pushed their edge on Indiana for the third spot in the Eastern Conference to three games with 11 remaining as they try to navigate the final stretch of the season rehabilitating the trio of injured rotation players — Jalen Brunson, Mitchell Robinson and Deuce McBride.

After struggling to shake the injury-depleted Mavs in the first half and entering the second half tied, the Knicks turned the game around in the third, opening up leads of as many as 16 points. In the fourth quarter they continued to pull away, allowing Towns to complete the triple-double with 6:28 left on a pretty feed to Mikal Bridges. And it allowed the Knicks to empty the bench and rest for the second half of a back-to-back set with the Clippers arriving for a Wednesday night game.

With Brunson still missing the Knicks needed a night like this where the offense ran smoothly, the team piling up 40 assists and finishing with celebrations all around. For Hart, it wasn’t just the triple-double, but going 6-for-9 from the floor, including both of his three-point attempts, was a sign that he was back on track.

“Means I played at least nine good games out of 60-whatever so far,” Hart said of the record.

“He got nine. I got one,” Towns said. “So he’s doing a much better job than me at getting triple-doubles. But the way he does it is special. It’s all energy and effort, and it’s for the betterment of the team.

“I’m just happy Josh gets stats on the sheet that show the impact he’s making on the game because I feel like there’s much more stats that don’t show up on the stat sheet that he does for our team. So I’m happy he’s having this moment where the effort, the sacrifice and the work he puts in for our team to be the best version of ourselves. It’s showing up on the stat sheet so he can get his respect, his accolades and all the cheers going on for him because he deserves it.”

The first half ran like a highlight reel offensively for the Knicks from the very start as Towns picked apart the Dallas defense, repeatedly finding cutters to the rim when he wasn’t draining three-point field goals or driving for dunks himself. By halftime Towns had piled up 24 points, seven assists and eight rebounds.

But that wasn’t enough for the Knicks to avoid being tied at 68 with the depleted Mavs at the intermission as Naji Marshall poured in 28 of his 38 points in the half. With Dallas missing Anthony Davis as well as a litany of rehabilitating or sidelined for the year players led by Kyrie Irving, they still managed to shoot 65.1% from the field in the half.

But the Knicks came out of the locker room with a different defensive mindset and Dallas misfired on 10 of its 11 attempts to start the second half as the Knicks opened up a double-digit lead

“It means a lot that we got it in a win,” Towns said. “At the end of the day, New York appreciates the wins more than the triple-doubles, so it’s perfect for the city that they got a ‘W’ on this day.”

Notes & quotes: McCullar, who made his NBA debut after sitting most of the rookie season while rehabbing a bone bruise in his knee before joining Westchester for 11 games, was thrilled to get the opportunity in his first chance at being on the active roster. “When I checked in, I was kind of in a fog,” he said. “Like, I’m really about to do it. And get in there and that’s what I worked for my whole life. So when I got out there and did it, it was relief for sure. Knowing that I’m back out there and competing and now got to keep building on it.”

Triple-Doubles X 2

For the first time in Knicks history and the 20th time in NBA history two teammates posted a triple-double in the same game.

Karl-Anthony Towns

Points Rebounds Assists

 26          12            11

Josh Hart

Points Rebounds Assists

16           12            11