Buffalo took control after Jordon Leopold pulled the Sabres even at 3 on a disputed goal at 4:26 of the third. During the play it appeared Stafford lost his balance skating near the crease and tripped Tampa Bay goalie Dwayne Roloson to the ice.
Goals by Tim Connolly (10:14), Thomas Vanek (11:01) and Stafford (11:56) put Buffalo ahead 6-3. Stafford completed the hat trick with a power-play goal that made it 7-3 with 6:33 to go.
Sean Bergenheim and Vincent Lecavalier each scored twice for Tampa Bay, which dropped to 4-2 during an NHL record-tying 12-game homestand. The Lightning are 22-2-1 when leading going into the third period.
Connolly's go-ahead goal came on a backhander after a Tampa Bay turnover. The Sabres are 11-4-1 in their last 16 games.
Buffalo, which started the season with 17 wins in the previous 20 games against the Lightning, beat Tampa Bay for the first time in three tries this season.
Bergenheim made it 3-1 on his second goal of the game at 11:24 of the second, coming on a rebound after Ryan Miller had stopped a shot by Ryan Malone. Vanek cut the deficit to 3-2 with 1:50 remaining in the period.
Lecavalier, off a pass through the slot by Victor Hedman, gave Tampa Bay a 2-1 lead 4:58 into the second. Lecavalier has scored in consecutive games following a stretch in which the Lightning captain had one goal in 16 games.
Bergenheim put the Lightning up 1-0 at 6:36 of the first. Stafford tied it with 3:17 left in the period.
Tampa Bay center Steven Stamkos, the NHL leader with 40 goals and 73 points, assisted on Lecavalier's second goal of the game, which came late in the third.
NOTES: Miller started his 29th consecutive game, five shy of tying his personal high. The team record is 39, set by Gerry Desjardins in 1976-77. ... Malone, who returned after missing five games, and Lightning D Matt Smaby both left with mid-body injuries. ... Buffalo D Steve Montador didn't play due to an upper-body injury. ... California, in 1975-76, is the only other NHL team to have a 12-game homestand. The Golden Seals went 4-7-1 during that stretch.