Sharapova needed to win in straight sets to have a chance of progressing in the tournament, and had to win the title 10 years after her first time if she was to topple Williams from the top of the rankings.
Sharapova inexplicably collapsed from a set and 5-1 up, missing three match points and losing the second set in a tiebreak. The Russian ultimately prevailed 7-5, 6-7 (4), 6-2 in over three hours but she will go home while Radwanska qualified for the semifinals despite a 1-2 group-stage record.
Since the rankings began in 1975, only five players have held the No. 1 spot at year end four times or more. The others were Steffi Graf (eight times), Martina Navratilova (seven), Chris Evert (five) and Lindsay Davenport (four).
Wozniacki finished top of her group with Radwanska second. Their semifinal opponents would be known late Friday, after Simona Halep faced Ana Ivanovic.
More From This Section
Halep would finish top of her group and Williams runner-up, unless Ivanovic won in straight sets, in which case the Serb and Halep would advance, with the order to be determined by percentage of games won through the tournament.
The Russian converted only two of six break points in that set, against two of three by Radwanska, and said she became too hasty as she tried to close out the match.
"A little impatient, her doing a good job of retrieving balls -- that is her strength -- and going for a little bit more than I should have," Sharapova said in explaining what went wrong in the second set.
For the match, Sharapova had a 61-12 advantage in winners, but committed 63 unforced errors against just 17 by the Pole.
Radwanska assumed she was going out in straight sets, so began to play looser tennis and it paid off in that second set.
"In that case you pretty much know that it's over, so you are more relaxed and she got tighter a little bit," Radwanska said. "It was easy for me to play, there are not so many nerves as early in the match.