Drew Stafford, who also had an assist, and Paul Gaustad scored goals for the Sabres, who hadn't won since defeating the Flyers here 3-2 on Nov. 14.
Mike Richards and Braydon Coburn scored for the Flyers, who returned home after losing three times on a five-game road trip.
Connolly lifted a wrist shot from the slot high over Philadelphia goaltender Ray Emery to break a 2-2 tie at 5:27 in the final period. He scored again at 10:18 when his shot bounced off Emery's mask.
Ryan Miller, who went into the game leading the NHL with a 1.98 goals-against average, made 31 saves, including a brilliant stop on a shot by Jeff Carter late in the second period.
Emery, who lost his third straight start, had 21 saves.
Stafford was credited with Buffalo's first goal at 8:19 of the first period when Philadelphia defenseman Matt Carle inadvertently knocked his back-hander into the net.
The Flyers scored twice within 30 seconds to take a 2-1 lead late in the period.
Richards went forehand to backhand to score at 19:26, then Coburn's shot deflected off Connolly with 3.6 seconds left.
Gaustad pulled the Sabres even on a power play at 6:09 of the second period when he redirected Connolly's shot from the point.
Buffalo's Craig Rivet and Philadelphia's Dan Carcillo went at each other twice within a 9-minute span in the second period and received 5-minute fighting majors both times. Carcillo was given a 10-minute misconduct penalty after the second fight. Rivet was helped off the ice with 3:22 left in the third period after being hit by Philadelphia's Arron Asham.
NOTES: The Flyers' Danny Briere served the second of a two-game suspension for a late hit on Colorado's Scott Hannan last Monday. ... Buffalo RW Patrick Kaleta received a 5-minute major penalty and a game misconduct for boarding Philadelphia C Jared Ross midway through the first period. Ross did not return. ... Philadelphia RW Ian Laperriere was hit in the face by a slap shot by Buffalo RW Jason Pominville late in the first period but returned in the third.