From there, he served out the match with confidence to complete a 6-3, 2-6, 6-4 victory and set up a quarter-final meeting with Kei Nishikori. He will next face Spain's Roberto Bautista Agut, who beat American Mackenzie McDonald 3-6 6-4 6-1. In his first outing since a surprise US Open fourth-round defeat to John Millman last month, Federer ousted the in-form Russian 6-4 4-6 6-4 in a high-quality encounter.
Federer's large cheering squad - decked out in matching red T-shirts - looked on in disbelief as Medvedev grabbed the second set.
The 37-year-old will be heading into the tournament, having won 13 of his last 16 matches.
However, as he did against Daniil Medvedev in round two, he stopped his opponent in his tracks at the death to advance to the final eight.
The Swiss great's prime threats in Shanghai are likely to come from world No. 3 Djokovic - who is in fine form - and world No. 4 Juan Martin del Potro.
Del Potro, the third seed, said that he is suffering from a virus and reviewing his health "hour by hour", after labouring past France's Richard Gasquet.
After his victory, he said: "It was extremely hard, that is why I was very happy at the end". I didn't run too much.
Third-seeded Del Potro, who has been playing with a cold throughout the week, was playing Borna Coric when he fell near the end of the first set.
1:56 Federer spoke to Sky Sports' Marcus Buckland after he reached the quarter-finals in China
The 26-year-old Basilashvili will now have another upset in his sights when he plays fourth seed Alexander Zverev at the Masters 1000 event on Wednesday. Focused a lot, focused on my game.
"I have given everything I had in today's match", said Zhang.
"China doesn't have a top-100 ranked male player yet".
"We played here past year and it was the place I got my first ATP win", Tsitsipas said.
Then a game later, he played another very poor game to gift the set to an ailing Del Potro 7-5.
The pair added that Li's shining example and the explosion of tournaments in China after her Grand Slam wins had triggered the emergence of a new generation of players. "Obviously he's playing the best tennis of his life, winning in Beijing, and obviously he had a very good match yesterday, as well".
The Serb will play either Italy's Marco Cecchinato or South Korea's Chung Hyeon next - he lost to both during his darker days in the first half of the year.
The victory gave the 21-year-old Zverev a tour-leading 49th match win of the year. "Bautista really had to raise his level of play in that second set to stay with me".
U.S. hurricane leaves homes unmoored, power lines damaged
Social media websites were crowded with messages from those trying to reach missing families in Florida's Bay and Gulf Counties. All told, more than 900,000 homes and businesses in Florida, Alabama, Georgia and the Carolinas were without power.