* Djokovic thwarts Murray's Shanghai hat-trick bid
* World number two digs deep to prevail (Adds quotes)
SHANGHAI Oct 14 (Reuters) - Novak Djokovic exacted revenge on Andy Murray for his U.S. Open final defeat by saving five match points to outlast the Briton 5-7 7-6 6-3 to win the Shanghai Masters title on Sunday.
The resilient Serbian fought back from the brink of defeat, trailing by a set and 5-3 before staving four match points in the tiebreak to force a tense decider.
The world number two then broke Murray, winner in Shanghai for the last two years, in the seventh game and again at 5-3, prevailing on his third match point to triumph when his opponent went long.
Djokovic had lost to Murray in their last two meetings, the U.S. Open final at Flushing Meadows in September in which the Scot secured his first grand-slam triumph, and the semi-finals of the Olympics in London.
"It was a thrilling match...very long - 3 1/2 hrs for best of three is quite long. But I have got used to it," Djokovic said.
"Whenever I play Andy I know it's going to be a gruelling fight, a lot of long rallies. It could have gone either way.
"I could not say I dominated the match because all three sets were very close and he had some match points and opportunities to finish the match. I could have easily been a runner-up today but I'm very proud of my fight."
An extraordinary topsy-turvy first set featured seven breaks, both players gaining an advantage before handing it straight back.
Djokovic led 2-0, world number three Murray 3-2 and Djokovic again at 5-4.
The decisive moment came when Djokovic went wide with a forehand volley to be broken for the fourth time and hand Murray a 6-5 lead.
His emotions boiling over, the angry Serb obliterated his racket with three hefty smashes before tossing it towards his chair, receiving a warning in the process.
Murray appeared to have another Shanghai title at his mercy when Djokovic fluffed his lines again and was staring at defeat at 5-3 down in the second set.
The Scot had match point on his own serve at 5-4 but a battling Djokovic dug deep, averted the danger and then seized his own chance to break back for 5-5.
Like the first set, a pulsating tiebreak swung back and forth with Djokovic staving off four match points, including two at 6-4 down.
He then spurned three set points himself before finally prevailing 13-11, taking the set with a driving forehand volley.
Murray had outlasted Djokovic at the U.S. Open in a five-set thriller, but fortunes were reversed this time in the Chinese port city with the Serb finding the greater stamina and willpower.
Sensing that his opponent was tiring, Djokovic broke to lead 4-3 in the decider, consolidated on his own serve and broke again to secure his fifth title of the season. He now leads Murray 9-7 in their head-to-head meetings.
"It was a disappointing one to lose but I've lost tougher matches than that before, in the biggest events, so I'm sure I'll recover from it pretty well," Murray said. (Writing by Justin Palmer in London, Editing by Clare Fallon and Pritha Sarkar)