Charlie Coyle had given the Bruins a 4-3 lead at 16:09 with a one-timer off a pass from behind the net by James van Riemsdyk.
"It's a shame we couldn't pull it off," Coyle said. "We had a couple of third-period leads and we can't afford to give those up. Good teams are going to keep battling like that, but we're a good team too. We have to make sure that we play the right way and are doing the right things, especially with a lead."
Tanner Jeannot put the Lightning up 1-0 at 6:39 of the first period when he charged the net and lifted a rebound over Swayman’s pad.
Pavel Zacha tied it 1-1 at 9:55 at the side of the net off a pass from Pastrnak after Boston forced a turnover on the forecheck.
Nicholas Paul put Tampa Bay ahead 2-1 with a power-play goal at 19:30 of the second period, redirecting a shot from Mikhail Sergachev.
"The effort level from the guys these last few games ... they're being rewarded for it," Cooper said. "It's not always perfect ... but I'm just really happy for the guys."
Pastrnak tied it 2-2 at 6:26 of the third with a shot from the point through traffic that beat Johansson to the glove side.
John Beecher gave the Bruins a 3-2 lead at 7:47 when he scored from the high slot after forcing a turnover.
"I loved how resilient we were," Montgomery said. "We just kept coming back. The belief on the bench was always that we were going to be able to win that game."