It was the fourth tiebreaking goal scored by the Rangers.
Pavel Zacha and Brian Gibbons scored second-period goals for New Jersey, and Jimmy Hayes, who is on a professional tryout contract, tied it 3-3 at 3:20 of the third period.
Kevin Hayes in the first period, and Chris Kreider and David Desharnais in the second each gave New York a one-goal lead. Kevin Shattenkirk had three assists, the last one on the game-winner.
"I think the only way we're going to get better is by playing with each other, and that's how you start figuring out your chemistry with guys," Shattenkirk said. "It was fun to get out here and play with some of these young guys who have a bright future, and for me to play with Brady [Skjei] and starting to get our chemistry as well."
Henrik Lundqvist made 11 saves and allowed two goals for New York in the first 30:09. Cory Schneider allowed three goals on 17 shots in the first 30:16 for New Jersey.