The Rangers celebrated a return to the post-season after Tampa Bay beat Carolina to give New York the eighth and final playoff berth in the Eastern Conference.
Vinny Prospal scored a goal and assisted on McDonagh's tally, which came at 11:59 into the second period and broke a 2-2 tie.
Prospal added an insurance goal with the only score of the third period of the regular-season finale.
Rangers captain Chris Drury was back in the lineup for the first time since suffering a knee injury in February and scored on a backhander early in the first period to tie the score 1-1.
Brandon Prust and Wojtek Wolski also scored for the Rangers. Henrik Lundqvist made 24 saves in the victory and shut out the Devils in the second and third periods.
Martin Brodeur also had 24 saves in goal for New Jersey. The Devils had goals from Nick Palmieri and Ilya Kovalchuk that gave them a 2-1 edge after one period.
There were only two penalties in the game, both at 5:53 of the second period. New Jersey's Vladimir Zharkov was called for slashing and Dan Girardi of New York was called for roughing.