Rasmus Ristolainen, Nick Seeler and Noah Cates also scored for Philadelphia, the No. 3 seed in the Metropolitan Division. Sean Couturier, Jamie Drysdale and Noah Juulsen each had two assists, and Dan Vladar made 29 saves.
Evgeni Malkin and Erik Karlsson scored for Pittsburgh, the No. 2 seed in the Metropolitan. Stuart Skinner made 24 saves.
The Flyers will have a chance to advance to the second round of the postseason for the first time since 2020 when they play Game 4 here Saturday.
Malkin gave the Penguins a 1-0 lead with a power-play goal at 4:18 of the first period, scoring off a seam pass through the crease by Bryan Rust. It gave the Penguins their first lead of the series.
Philadelphia then scored three goals in a 6:00 span in the second period to take a 3-1 lead.
Zegras tied it 1-1 on the power play at 5:18. His one-timer from the right face-off circle went past Skinner's glove.
Ristolainen put the Flyers ahead 2-1 at 9:06 with a shot from the right face-off circle between Skinner's pads.
Seeler then made it 3-1 at 11:18 when he scored from the point.
Karlsson scored a power-play goal to make it 3-2 at 9:39 of the third period, one-timing a pass from Rickard Rakell that found space between Vladar's right arm and body.
Cates put the Flyers ahead 4-2 when he scored a power-play goal at the net front at 12:30.
Owen Tippett scored an empty-net goal at 18:48 for the 5-2 final.