This one ended just about the only way it could for the Rangers — on a sloppy move that teetered on disaster.

But it was 20-year-old rookie J.T. Miller winning it in a shootout for the Blueshirts last night at the Garden, 2-1 over the Hurricanes, snapping a three-game losing streak with a move that was less artful than it was effective.

“I almost dunked it in the corner, so it felt even better to see it go in,” a smiling Miller said after his attempted backhand in the third run of the skills competition bounced over his stick to his forehand, where he managed to sneak it by Dan Ellis and send the crowd of 17,200 cheering out of the building for what feels like the first time in weeks.

“We worked really hard to come back in that game,” Miller said, “and we deserved it as a team.”

Henrik Lundqvist (29 saves) stopped the two chances the Hurricanes had, and Rick Nash netted one on the Rangers’ first attempt — but from the second period forward, the result seemed inevitable.

“We were a different team in the second and third, and overtime,” coach John Tortorella said. “We generated [scoring chances] and played very well in those three periods.”

Added Miller: “In the second period, as a team, we outplayed them. We just carried that over to the third.”

The Rangers (14-12-2) were coming off a horrid 1-3-0 road trip that saw them fall out of the playoff picture after scoring just two goals in the final three games. So as they came out for this first period and watched Eric Staal score his 14th of the season with less than a minute to play in the frame, breaking a scoreless tie, the sound of the tombstone engraver was as audible as the boos from the home fans.