SHANGHAI, China -- Roger Federer was tired, his back was aching and he trailed 3-0 in the deciding set. Still, he wasn't about to end his pursuit of a fifth Masters Cup title.
So Andy Murray finished it for him.
Murray rallied Friday for a 4-6, 7-6 (3), 7-5 victory that raised his career record against Federer to 4-2, making him one of the few players to have an edge over the Swiss star.
It was a dramatic conclusion to group play at an event that has largely lacked compelling play. Fans in packed Qi Zhong stadium were on the edges of their seats for three hours.
"It was a great match," Murray said. "So many sort of twists and turns."
Murray kept up his chance to double his prize money by going undefeated through the season-ending tournament. He'd already qualified for the semifinals, and he could have tried to save energy for his next match looming in less than 24 hours.
No way. Not against Federer, whom he didn't want to face again if both were to reach the final.
"A win over Roger Federer means almost as much as winning the Masters Cup to me," the fourth-ranked Briton said. "He's the best player of all time. He's still playing great. I know I'm going to be tired tomorrow, but this match meant a lot to me.
"Psychologically, a win like that is going to be huge for me next time I play him, especially in big matches."
Murray lost to Federer in straight sets for the U.S. Open championship in September. It was Murray's first Grand Slam final.
Murray earned a meeting against Nikolay Davydenko that, given the Russian's baseline style and strong defense, shapes up to be a long, difficult struggle, too. His victory also benefited fellow Masters Cup newcomer Gilles Simon, who earlier beat Radek Stepanek in a meaningless match.
On this day, all that mattered was Murray vs. Federer, who knew he would advance if he won and go home if he lost.
Federer's problem back forced him to withdraw during the Paris Masters two weeks ago and affected his sturdy serve here. Then he came down with a stomach ailment earlier in the week here that eroded his stamina.
"I don't quit once I step on court," Federer said. "Normally, best of three match, it's peanuts. So it was a pity I couldn't handle it today. Pretty happy I don't have a match tomorrow, to be honest.
"I almost made a miracle happen, you know," Federer said, who is looking forward to trying to get healthy during the offseason. "I can't believe how close I got, to be honest. So I'm actually very happy."
Refusing to go without a struggle, Federer saved seven match points while serving at 4-5 in a game that lasted 17 minutes and went to deuce 10 times. Murray converted his next chance two games later, breaking when Federer sent a forehand long.
"When you play against Roger, you got to expect him to play some great stuff, especially when he's behind," Murray said. "He hit a couple of aces, a couple of big forehands. I missed a couple of returns I maybe shouldn't have."
Federer, trying to repeat last year's feat of coming back after losing his opening-round match, was hoping to force another tiebreaker but committed three forehand errors while serving at 5-6. He then wearily trudged off court with a brief wave to the fans who overwhelmingly supported him.
"I thought the atmosphere was awesome," Murray said. "I think it makes the result even better for me that most of the crowd wanted him to win."
Federer began the year recovering from a bout of mononucleosis. He lost the French Open and Wimbledon finals to Rafael Nadal, who finally overtook him for the No. 1 ranking. But he won the Olympic doubles gold, then his fifth straight U.S. Open to pull within one of Pete Sampras' record of 14 Grand Slam titles.
"It's been a good year, you know," Federer said. "Tough to start off with. Tough to end. But I think it gives me the opportunity to start over all new again next year."
The match was the highlight of a tournament that had seen few of them and had flaws exposed in the round-robin format and substitution system.
Nadal pulled out with knee tendinitis before it began, allowing the ninth-ranked Simon into the field.
Andy Roddick withdrew after his first match with a sprained ankle sustained in practice, leading to the addition of 26th-ranked Stepanek. He was eliminated after losing his first match, playing with borrowed rackets because his gear didn't make it through Chinese customs in time -- they finally showed up minutes before his match against Simon.