Fredrik Claesson and John Hayden also scored, and Damon Severson and Dakota Merkis each had two assists to help the Devils improve to 6-1-2 in their last nine games.
''As a group we stepped up,'' Palmieri said. ''It was great to contribute and see those two go in. It was fun.''
Mackenzie Blackwood stopped 31 shots to improve to 8-1-2 in his last 11.
''Everyone is doing their job,'' Blackwood said. ''This is huge for us. We know what we had to do.''
Mika Zibanejad, Tony DeAngelo, Filip Chytil, and Greg McKegg each scored for the Rangers, who fell three points out of the two wild-card spots in the Eastern Conference.
''(Our mindset) was to play spoiler,'' Zajac said. ''It's an important time for them in the season, so it makes it sweeter for us.''
Igor Shesterkin allowed five goals on 23 shots over two periods in his first game since sustaining a rib fracture in a car accident on Feb. 23. Henrik Lundvist replaced him to start the third and stopped all five shots he faced.
The Devils trailed 2-1 after one period before scoring four times in the second to take control.
Palmieri got his second of the night and 25th of the season just 44 seconds into the middle period to tie the score.
Claesson, who played 37 games for the Rangers last season, gave the Devils the lead for good just 52 seconds later. It was his first goal in five games this season.
Zajac pushed New Jersey's lead to 4-2 on its first power play of the night with less than four minutes remaining in the second.
Hayden made it 5-2 just 25 seconds later, snapping a 14-game point drought.
''Want is a very, very important characteristic in this sport,'' Rangers coach David Quinn said. ''We played a team that wanted it much, much more than we did.''
The Rangers cut their deficit to 5-3 with 6:18 left in the third on McKegg's fifth of the season.
Zajac scored his second goal of the game on an empty net in the final minute, moving past Zach Parise for fourth place on the franchise list with 195 goals.
DeAngelo pulled the Rangers to 6-4 just 13 seconds later, but that was as close as the Rangers got.
''They were better than us in every capacity,'' Quinn said.
The first period was punctuated by three goals in less than two minutes. Chytil opened the scoring for the Rangers 5:34 into the game, converting from the slot after receiving Julien Gauthier's pass from behind the net. The goal ended a seven-game point drought for Chytil.
The Devils tied it 1-1 only 48 seconds later, as Palmieri beat Shesterkin from a tight angle. But New York regained the lead just 56 seconds after that. One game after a historic five-goal performance against the Capitals, Zibanejad found the back of the net once again. The 26-year-old has 21 goals in his last 20 games.
The Devils came close to tying the game in the first period, with Kevin Rooney failing to score on a breakaway.
''Guys are playing for roster spots,'' New Jersey coach Alain Nasreddine said. ''There is an urgency to our play. I liked the way we skated these last two games against two very strong teams.''
This was the final meeting of the season between the Devils and the Rangers, with each team earning two wins.
NOTES: The Rangers moved F Kaapo Kakko down to the fourth line, switching him with Gauthier. ... New York scratched injured F Chris Kreider and G Alexandar Georgiev. ... The Devils scratched injured D Will Butcher and F Janne Kuokkanen, who was recalled from Binghamton (AHL) before the game.
Devils: Host Pittsburgh on Tuesday night.
Rangers: At Dallas on Tuesday night to open a three-game trip.
More AP NHL: https://www.apnews.com/NHL and https://www.twitter.com/AP-Sports
Copyright 2020 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.