All that stood between Carmelo Anthony and his first triple-double in nearly four years were two assists, and there were 12 minutes remaining. But he spent the final quarter watching the action from the bench, a gray sleeveless shirt covering his jersey.

His night was done, and for the Knicks, perhaps there was no better sight. Rest agrees with him.

Anthony returned Friday night from a two-game absence in which he nursed a sore knee, and his all-around game looked better for the break. He had 19 points, 10 rebounds, eight assists and four steals as the Knicks avoided their first five-game losing streak of the season with a comfortable 102-84 victory over the Phoenix Suns at Madison Square Garden.

With the defending champion Golden State Warriors up next Sunday night, the Knicks needed to experience something positive. Arron Afflalo added 17 points as five players scored in double figures for the Knicks, who took advantage of a Suns team that has been reeling. The Suns have lost nine of their last 10 games and 18 of 20, leading to speculation about coach Jeff Hornacek’s job security.

Devin Booker, the youngest player in the NBA at 19, had 21 points for the Suns.

As the Knicks seek to stay within reach of a playoff berth, they delivered exactly the type of dominant performance expected at home against a lesser opponent. And even though they were playing the second night of a back-to-back, they clearly were the better team, turning the ball over only eight times and forcing 16 Suns turnovers.

And their best player led the way.

Anthony’s much-talked-about growth as a distributor this season was best personified by a moment just before halftime in which he passed up the last shot.

With time running out in the half, Anthony had the ball just inside the three-point line, no doubt thinking about hoisting the final shot. But he couldn’t lose Suns defender P.J. Tucker no matter how many twists, turns and crossovers he tried.

It’s almost certain that in past seasons, Anthony still would have taken a contested last-second shot on what was an otherwise broken final set. Not this year. Not this night. With no more than two seconds on the clock, Anthony saw teammate Sasha Vujacic standing all alone to his left, several feet behind the three-point line. So he passed on the final shot, seemingly to the surprise of many of the Suns players on the court.

Vujacic, however, wasn’t surprised. He had just enough time to catch and shoot from well beyond the arc, and the shot rattled through the rim, putting a resounding end to a strong opening half.

Vujacic’s three-pointer, his only basket of the half, opened an 18-point lead. It also marked Anthony’s sixth assist in only 18 minutes.

“He didn’t try to take over the game too much,” Derek Fisher said. “That decision helped him see the floor.”

Fisher acknowledged before the game that even though Anthony said his knee felt better after a two-game absence, the Knicks wouldn’t know just how well he felt until it was tested in the intensity of a game setting. But Anthony showed no ill effects, and — to no one’s surprise — the Knicks clearly were a significantly better team with him on the court. He was plus-33 in 30 minutes.

The Knicks also welcomed back Kristaps Porzingis, even though Fisher said before the game he didn’t expect him at top strength after missing Thursday night’s game because of an upper respiratory illness. Porzingis, seen coughing into his elbow at times, had seven points and seven rebounds in 24 minutes.