In another entertaining matchup between the two U.S. Open finalists, Djokovic seemed headed for defeat when Murray was serving for the match at 5-4 in the second set.
But the second-ranked Serb saved one match point in that game before breaking back for 5-5. He then saved four more in a tense tiebreaker and carried his momentum into the deciding set, breaking the Briton twice to earn his fifth title of the year.
It was Murray's first loss in Shanghai in 13 matches.
Murray, who beat Djokovic in five sets at Flushing Meadows for his first Grand Slam title, saved two match points in the final game, but sent a backhand long on the third.
In a matchup of two of the game's best returners, both players struggled to hold serve early, trading breaks three times, and were tied 4-4 in the first set.
When Djokovic was broken for the fourth time in the 11th game, he lost his cool and shattered his racket by smashing it into the ground four times before slinging it disgustedly toward his sideline chair.
But the momentum seemed to shift with one audacious shot from the Serb, just as Murray appeared to be closing in on his third straight title at the tournament.
Trailing 5-4 and 30-0 in the second set, Djokovic chased down a lob from Murray and hit a perfect between-the-legs shot, then followed it up with a drop shot to win the point. He went on to save Murray's first match point with a forehand and broke back when the Briton missed a forehand of his own two points later.
In the 20-minute tiebreaker, Djokovic finally prevailed when he converted his fourth set point with a forehand winner.
Murray couldn't recover, and Djokovic broke for a 4-3 lead before winning the next two games to wrap up the win.