Keith Kinkaid, playing his first game since March 28, made 28 saves before leaving with an injury at 8:50 of the third period. Igor Shesterkin made seven saves in relief.
"Especially in the third, I thought we played really well," Zibanejad said. "And obviously it's a really good team that we're playing against, and I thought we got better as the game went on. Got the win and got to finish the season somewhat in a nice way. "
K'Andre Miller scored at 6:21 of the second period to give the Rangers a 1-0 lead. Nick Ritchie tied it 1-1 at 18:12.
Pastrnak gave the Bruins a 2-1 lead 21 seconds into the third period.
The Rangers then took the lead with three goals in a span of 4:14.
Zibanejad scored at 5:22 to tie it 2-2, before Alexis Lafrenière gave the Rangers a 3-2 lead at 7:25, and Vitali Kravtsov made it 4-2 at 9:36.
"Obviously a tough start in the third period," Pastrnak said. "I think they definitely came up hard and felt we [weren't] ready, which is obviously unacceptable. You know, we played a great 40 minutes. It was a tough lesson, but we're going to learn and move on and we need to be 100 percent ready for the next week (playoffs)."