Teddy Blueger scored two goals, and Nick Bjugstad, Justin Schultz and Matt Cullen each had one for the Penguins. Pittsburgh fell behind 2-0 before scoring five straight goals, including three in the second period.
Matt Murray made 33 saves. He is 6-0-0 against the Rangers in the regular season, including 5-0-0 in New York.
"We're still getting there, we still have things to get better at," Bjugstad said. "We had a rocky start here tonight, but we held our composure. We have [five games] left, it's important to have some momentum and some confidence going into the playoffs."
Brendan Lemieux and Vinni Lettieri scored in the first period for the Rangers (29-33-13), who have been eliminated from Stanley Cup Playoff contention. Alexandar Georgiev made 31 saves.
"We got a little sloppy, our puck management, the way we were playing," New York defenseman Brady Skjei said. "The first period we played really solid, we were all over them and then just kind of got away from that in the second, third."
Lemieux gave the Rangers a 1-0 lead at 8:25 of the first period, scoring off the rush from the right circle. Lettieri extended the lead to 2-0 with a power-play goal at 15:15.
The Penguins responded 26 seconds later with a goal from Bjugstad off a rebound to make it 2-1.
"We started to pour it on after that," Bjugstad said.
Schultz scored a power-play goal on a one-timer off a pass from Sidney Crosby at 1:01 of the second period to tie the game at 2-2.
Cullen gave the Penguins a 3-2 lead at 7:17 of the second, scoring from the bottom of the right circle.
Blueger made it 4-2 with a shorthanded goal at 13:12 of the second. He scored again at 7:38 of the third period to make it 5-2.
The Rangers were assessed a minor penalty for delay of game after they unsuccessfully challenged Blueger's second goal for offside.
"We know we have the firepower in here to get back in those kind of games," Blueger said. "It's not the first time we've been down so we didn't get down on ourselves. We just kept pushing, kept pushing each other and got back into it."