Scott Hartnell had a goal and two assists, and Wayne Simmonds set up two goals in helping Philadelphia snap a two-game skid. Jakub Voracek also scored for the Flyers (24-19-4), who improved to 8-3 in their past 11 games.
Cody Hodgson and Matt D'Agostini each had a goal and assist for Buffalo, which had an eight-game home point streak snapped at 6-0-2. Tyler Ennis also scored and Steve Ott set up two for the Sabres (13-27-5).
Lecavalier's goal came during a scramble in the Sabres zone. Flyers forward Matt Read dug out a loose puck to the left of the Buffalo net and fed Lecavalier, who one-timed a shot from the left circle.
The goal capped a furious finish in which the teams traded leads twice by combining to score four times in the final 6:32.
The Flyers twice rallied from one-goal deficits, and took a 3-2 lead on Hartnell's power-play goal with 4:07 left in the third period.
The Sabres tied it 54 seconds later, when Ennis' one-timer from the right circle sneaked in under goalie Steve Mason's pad.
Lecavalier nearly sealed it 50 seconds later, when his centering pass from the lower left boards struck Sabres defenseman Mike Weber in front, and fluttered toward the net. Buffalo goalie Jhonas Enroth dropped his stick and managed to smother the puck in the crease.
Enroth was sharp in stopping 29 shots, and made a highlight-reel save on Claude Giroux 12 minutes into the first period.
Sabres forward Ville Leino also made a big stop 12 minutes into the second to bail out Enroth, who had slid out of position. Read took a shot at an open right side only to have Leino - the former Flyers forward - stop the puck in the crease with his stick.
Brayden Schenn also scored for Philadelphia, which rebounded from back-to-back defeats, including a 4-1 loss at the New York Rangers on Sunday.
The Sabres squandered a chance to win consecutive games for only the third time this season.
It was a disappointing finish particularly for D'Agostini, who was claimed by the Sabres off waivers in late November. He was playing on Buffalo's newly formed top line centered by Hodgson, who played his second game since missing eight with a thumb injury.
D'Agostini earned his 100th career point with an assist on Hodgson's game-opening goal, and then made it 2-1 with 6:32 left in the third.
Despite opening the scoring, the Sabres failed to carry any momentum. They were outshot 10-0 during a 13-minute stretch spanning the first intermission. It was during that stretch when Voracek tied the game 1:40 into the second period.
NOTES: Sabres D Tyler Myers is eligible to return at Toronto on Wednesday after sitting out the third and final game of his suspension for an illegal check to the head of New Jersey forward Dainius Zubrus. ... Read returned after missing six games with concussion-like symptoms. ... Sabres President Pat LaFontaine said he thinks the team and rookie center Mikhail Grigorenko are "on the same page" regarding the 2012 first-round pick's development after the player initially balked at reporting to his Canadian junior team in Quebec City last weekend. LaFontaine said Grigorenko needs to develop by continuing to play, which would not have happened if he stayed in Buffalo with the 17-day Olympic break approaching next month. "We're doing what we think is best to develop our players," LaFontaine said. "I really believe under all the circumstances, that (Quebec City) is the best place for him."