Oilers had grabbed a 3-2 lead on David Perron's power-play score midway through the final period, but Ales Hemsky and Jeff Petry were each whistled for a minor penalty moments later, setting up a 5-on-3 advantage for the Flyers.
Hartnell tipped in a Kimmo Timonen shot with 5:32 remaining to forge a 3-3 tie.
Steve Mason stopped Sam Gagner in the third round and Raffl, making the first shootout appearance of his career, faked Ilya Bryzgalov to the ice before potting a shot from a sharp angle for the game-winner.
Wayne Simmonds scored two regulation goals and Mason finished with 13 saves for Philadelphia, which began a six-game road trip with a win.
Taylor Hall provided a goal and an assist for the Oilers.
Ryan Nugent-Hopkins also scored and Bryzgalov made 35 saves.
Former Titans kicker dies in car crash
UPI Sports Results for September 20, 2014