An emotional Serena Williams battled through the pain barrier to overcome Jelena Jankovic 6-4 2-6 6-4 and set up a showdown with Li Na in the final of the WTA Championships.
The world No 1 and defending champion appeared to be physically compromised and twice sat weeping into her towel during changeovers.
She also committed 40 unforced errors and hit 40 winners, and allowed a 5-1 final set lead to evaporate to within one point of 5-5 before finishing the match with three trademark heavy blows after two hours and six minutes at the Sinan Erdem Dome in Istanbul.
Jankovic was unsure whether she would be able to play her best because of a cold but the Serbian made a great start, winning three of the first four games.
Williams has looked in supreme shape this week but her fearsome serve lacked its usual bite and she was not moving well at all.
At 2-3 down the American won 10 straight points as she went for broke and going on to take the first set.
Jankovic quickly took charge in the second, though, and this time there was no Williams comeback.
Remarkably, it was the first set the 32-year-old had lost at the tournament to anyone other than her sister Venus since 2007.
From 1-1 in the decider, Williams won four straight games, but there was another twist. She missed a match point at 5-2, and suddenly it was nerves rather than physical problems that seemed to be affecting her.
Two more match points came and went in the 10th game before finally Williams clinched it at the fourth time of asking for her 77th win of the year.
"Last night I was lying down and I hit a wall," said Williams, presumably figuratively speaking.
"And since then I have had no energy. In the match I was struggling for energy to play at all. I have played a tremendous amount of matches and it isn't easy."
She added: "I'm just relieved and just glad to be in the final."
In the final on Sunday she will bid for her fourth title at the year-end championships and 11th trophy of an extraordinary season against Li Na.
The Chinese player ensured she will end 2013 as the world No 3 after cruising past Petra Kvitova 6-4 6-2.
Having lost the first three games, two of which were on her serve, 2011 champion Kvitova did well to claw her way back to 4-4, but Li broke again before clinching the set.
The fourth seed then forged ahead in the fifth game of the second set and finished the match with a run of four games in a row.
The victory guarantees Li will leapfrog both Maria Sharapova - absent from the tournament with a shoulder problem - and Agnieszka Radwanska.