Roger Federer brought Novak Djokovic's three-year unbeaten run indoors to an end to secure a semi-final place at the ATP World Tour Finals.
The Swiss six-time champion won 7-5 6-2, ensuring he will progress from the group stage with one match remaining.
Djokovic, winner of the past three season-ending titles in London, had won his previous 38 indoor matches.
The Serb will play Tomas Berdych in his final group match on Thursday and can still qualify for the last four.
Federer will play Japan's Kei Nishikori, who beat Berdych 7-5 3-6 6-3 in the afternoon session.
"It's always a thrill to come out here, even more so against a great player like Novak," said the 17-time Grand Slam champion.
"It's a special night for tennis, and a cool atmosphere."
|Name||Played||Won||Lost||Sets F-A||Games F-A|
|Roger Federer (Q)||2||2||0||4-0||25-13|
'I handed him the win'
The packed O2 Arena crowd of more than 17,000 spectators was largely behind Federer, as ever, but even the 34-year-old's most diehard fans must have been surprised by a straight-set win.
Djokovic, 28, had not been beaten anywhere since he lost to the Swiss in Cincinnati three months ago, and the world number one's last defeat at the O2 came in 2011.
His form dipped dramatically after a tight first set, with the Serb winning just 25% of points on his first serve and searching for his usual metronomic accuracy.
|Andy Murray column|
|"My wife Kim is expecting our first child and it's really nice that when I get home I'm not stressing about tennis, but interested in helping her as much as I can."|
|Read his BBC Sport column|
"You have those days when you are not feeling your best, not even close to the best," said Djokovic.
"Credit to Roger for mixing up the pace, giving me always a different ball. He used the slice and spin very wisely. He served very efficiently.
"I made a lot of, lot of unforced errors. I just handed him the win, especially in the second set."
Mixing up tactics pays off for Federer
Federer had to fend off a break point in the opening game but the next 40 minutes saw both men dominant on serve.
With a tie-break looming it was Federer who made the decisive move, missing a forehand on his first set point but playing a fabulous half-volley to convert the second.
A rash of attacking returns saw the Swiss move into a 2-0 lead in the second set but he then handed it straight back with an edgy service game.
The expected Djokovic fightback did not materialise though - instead the Serb played a dreadful service game and could only watch as a rasping Federer backhand made it 4-2, a lead he would not relinquish.
"The tactic was to mix it up, I have to against Djokovic," said Federer. "I hit it well out wide today. I knew it was an important serve to get Novak off the court."
Nishikori comes through Berdych test
Eighth seed Nishikori let an early lead slip and saved a break point in the deciding set before beating Berdych 7-5 3-6 6-3.
Berdych recovered from an error-strewn start that left him a set and a break down to move within sight of victory with a break point at 3-3 in the decider.
"I think it's been all about one point in the third set when I had the break point," said the Czech sixth seed.
"I had him on the run. The rally starts pretty well for me, but I was not able to break him. Then I lost my serve. Basically, that was it. That was the difference."
Nishikori said: "That was a really big point. He had three, four shots that he went really aggressive.
"I was on defence all the time. The last shot I kind of went for it, closed my eyes. I was a little bit lucky I made that shot."
First defeat for Murray & Peers
In the doubles, Britain's Jamie Murray and Australian John Peers suffered their first defeat at the event in their second group match.
India's Rohan Bopanna and Florin Mergea of Romania won 6-3 7-6 (7-5) to secure the first semi-final place.
Murray and Peers won their opening round-robin match, so can still claim the second qualification spot.
They will take on Americans Bob Bryan and Mike Bryan in their final group match on Thursday.
"It's an exciting match to play," said Murray. "I guess we have to win if we want to try to stay in the competition.
"It will be nice to get out there and play with a full crowd again. They always bring a lot of energy to the court. We have to do the same if we want to try to win."