Tyler Johnson had the other goal for Tampa Bay, which moved within a point of Montreal for second place in the Atlantic Division.
Wayne Simmonds and Sean Couturier scored for the playoff-bound Flyers, who are tied for third in the Metropolitan Division with Columbus.
Anders Lindback played in place of injured Tampa Bay starting goalie Ben Bishop, who may not be ready for the start of a playoff series next week against Montreal due to an upper-body. Bishop, 37-14-7 this season, left Tuesday night's game against Toronto early in the first period after it appeared he hurt his left elbow.
Lindback made a glove save on Tye McGinn's in-close rebound with 8 minutes left in the first. He came off the bench Tuesday and made 25 saves in a 3-0 victory over the Maple Leafs.
Panik won a race for the puck behind the net, moved out front and gave Tampa Bay a 2-1 lead on a back-hand rebound of his own shot 4:33 into the third. It stopped the right wing's 17-game goal drought.
Brewer extended the advantage to 3-1 when he beat Ray Emery from the left circle at 9:43 of the third.
After the Flyers pulled within one when Tampa Bay's Ondrej Palat deflected Couturier's pass past Lindback at 12:22, Stamkos' power-play goal made it 4-2 with 5:46 remaining.
Stamkos setup Johnson's goal from the left circle 2 minutes into the game. Johnson set a team rookie record, breaking the mark set by Stamkos, with his 24th goal this season.
Simmonds tied it at 1 on an in-close turnaround goal during a power play with 1:21 to go in the second. The Flyers entered with the NHL's top-ranked road power play.
Emery turned aside two good scoring chances by both Stamkos and Ryan Callahan during a second-period Tampa Bay power play.
Notes: Tampa Bay D Michael Kostka returned and had two assists after missing three games with a concussion. ... The Flyers have lost six straight road games against Tampa Bay. ... Lightning D Sami Salo sat out with an undisclosed upper-body injury.