Messier skated behind the net and reversed direction before finding Barnaby at the bottom of the left faceoff circle for a one-timer that got past goaltender Martin Brodeur.
It was the sixth goal of the season for Barnaby, who also set up Chad Wiseman's first NHL tally 42 seconds into the third period. New York erased a pair of deficits in the third.
Anson Carter also scored for the Rangers, who moved to 1-21-13-1 in the last 36 regular-season meetings with the Devils, including 0-6-10-1 at Madison Square Garden. They have earned a point in the last four games overall (2