Stamkos scored with a slap shot on a 2-on-1 with Mikhail Sergachev seconds after Bruins forward David Pastrnak could not score on a breakaway.
"I had a lot of time to think about what to do. ... I just wanted to blast one there, and it's nice to see it go in," Stamkos said. "[Andrei Vasilevskiy] stole us one tonight, no doubt about that. I know we had the two-goal lead, but it didn't really feel that way."
Vasilevskiy made 37 saves, and Taylor Raddysh and Ondrej Palat scored for the Lightning (14-5-4).
"In an 82-game league, it's hard to play your best, and sometimes you have some stinkers. Tonight was a stinker," Tampa Bay coach Jon Cooper said. "[Vasilevskiy] was on, which we needed. … We came out with two points against [an Atlantic Division] rival, so we'll take these and run."
Charlie Coyle and Curtis Lazar scored for the Bruins (12-8-1). Jeremy Swayman made 23 saves.
"I think our guys played real well tonight, especially being down 2-0 to that team, but even when we were down 2-0, we were playing a good, solid game," Boston assistant coach Joe Sacco said. "We played hard tonight and competed. Really nobody took the night off. ... Unfortunately we don't get the end result, but we can build off that game for sure."