Pastrnak's one-timer from the left point on the power play cut it to 4-3 at 6:37.
Nikita Kucherov scored into an empty net with 1:02 remaining for the 5-3 final.
There were 94 penalty minutes in the game; 48 for Tampa Bay (14 penalties), 46 for Boston (12).
"Obviously we didn't get the two points, but I think the way that everybody played hard and everybody played physical no matter who it was, I think there was a good response [after] going down 3-0 and making it a game," McAvoy said. "And sometimes it doesn't go your way, and that was kind of what happened tonight. But we'll take some positives from it, get back on the horse."