Nolan Patrick, Jordan Weal and Jakub Voracek scored for Philadelphia, which was looking to sweep the California portion of its trip after beating Anaheim and Los Angeles earlier in the week. Oskar Lindblom had two assists and Cal Pickard stopped 29 shots in his third start.
Meier's winning goal was his 11th on the season, and eighth in his last seven games.
Thornton's first goal of the season with just under 5 minutes left in the third tied the score 3-3.
Voracek had given the Flyers the lead with 30 seconds remaining in the second.
Patrick opened the scoring just 37 seconds into the game, and Meier tied it at 3:15.
Weal put the Flyers back ahead with 3:20 left in the opening period, but Pavelski evened the score again just past the midpoint of the second.
NOTES: Flyers G Michal Neuvirth (lower body injury) was sent back to Philadelphia to meet with team doctors. ... Sharks coach Pete DeBoer shook up his team's lineup, moving F Evander Kane to the first line and returning Meier to the second line. Rookie C Rourke Chartier skated on the third line in place of rookie Antti Suomela, a healthy scratch.
Flyers: Conclude their four-game road trip on Monday in Arizona.
Sharks: Host Minnesota on Tuesday.
More AP NHL: https://apnews.com/NHL and https://twitter.com/AP-Sports
Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.