K'Andre Miller also scored, Vitali Kravtsov had an assist, and Louis Domingue made 10 saves on 11 shots in 32:06 for New York. Jaroslav Halak made 15 saves in relief.
Jack Hughes scored, and Mackenzie Blackwood made 35 saves for New Jersey, which lost for the first time this preseason (3-1-0).
Hughes gave the Devils a 1-0 lead at 2:21 of the second period from the top of the right circle. Ondrej Palat, who signed a five-year, $30 million contract with New Jersey on July 14, had the assist on the play.
Panarin tied it 1-1 at 3:48 of the third period, scoring from the left circle off a cross-ice pass from Braden Schneider.
Miller put the Rangers in front 2-1 at 11:46 when his point shot went in off Devils forward Zach Senyshyn and defenseman Thomas Hickey.