Roger Federer has guaranteed himself a record 300th week as the World No 1 after surviving a massive scare from compatriot Stanislas Wawrinka in the Shanghai Masters.
Federer was second best for much of the first two sets but eventually prevailed 4-6 7-6 6-0 after a gripping third round clash which lasted almost two hours.
Wawrinka won the opening set after breaking for a 4-3 lead in game seven, before the duo traded breaks at the start of set two.
Federer then managed to save a crucial break point, which would have given Wawrinka the chance to serve for the match at 5-4.
A tense tie-break followed and, although Wawrinka brilliantly chased down a net-cord and flicked a cross-court winner to save one set point, he then put a shot wide to lose the tie-break 4-7.
And that led to a complete change in the momentum of the match, Federer powering through the final set to set up a clash with 10th seed Marin Cilic of Croatia.
"I consider myself a little lucky," said Federer. "I never stopped believing and pushed till the end, then got off to a good start in the third set. It was a tough match, he was better for basically two sets.
"So here I am at 300 weeks. It's pretty incredible and probably one of my biggest accomplishments. I'm very proud of that record, no doubt about it."
Novak Djokovic is also through to the quarter-finals after a routine 6-3 6-3 victory over Feliciano Lopez and he will play German veteran Tommy Haas in the last eight.
Berdych digs deep
Fellow seeds Tomas Berdych and Jo-Wilfried Tsonga also progressed to the quarter-finals and kept their World Tour Finals qualification bids on track with contrasting victories.
Czech fourth seed Berdych dug deep to overcome American Sam Querrey 6-2 6-7 (3-7) 6-4, while Tsonga eased past Marcos Baghdatis 6-2 7-6 (7-2).
Stepanek booked a last eight date with Andy Murray and dented John Isner's hopes of reaching the season-ending event in London with a hard-fought 6-4 6-7 (5-7) 6-3 victory.