Roger Federer stayed on course for a third successive Masters Cup title with a hard-fought 6-3 2-6 7-6 (7-4) win over Ivan Ljubicic in Shanghai. And the world number one became the first player through to the semi-finals when Argentina's David Nalbandian beat compatriot Guillermo Coria 7-5 6-4.
It was the Swiss player's second victory of this year's event after an opening win over Nalbandian.
"I'm definitely not 100%, I think that's obvious," said Federer.
"I expected to lose a close match. I thought he was even slightly the favourite."
Federer appeared to be cruising when he took the opening set, but was twice broken as his Croat opponent hit back to take the second.
The momentum shifted again in the fifth game of the decider as the Croat double faulted on break point to go 3-2 down.
Federer had treatment from the physiotherapist at the start of the third set and Ljubicic saved three match points before Federer took the tie-break 7-4 to secure his 42nd straight victory on hard courts.
Meanwhile, world number 10 Nalbandian outmuscled Coria in the first set of their encounter and dictated the pace in the second.