James Van Riemsdyk and Matt Read also scored for Philadelphia and Sergei Bobrovsky made 23 saves.
Fabian Brunnstrom scored for Detroit and Jimmy Howard stopped 19 shots.
Van Riemsdyk and Jagr scored 52 seconds apart late in the first period to erase the Red Wings' 1-0 lead.
Van Riemsdyk tied it 1-all with 2:34 left in the opening period and Jagr gave the Flyers the lead for good with 1:42 remaining in the first.
The Flyers' victory came a night after a banana was thrown from the stands as Wayne Simmonds scored during a shootout. Simmonds, who is black, did not play Friday night but was seen signing autographs.