David Ferrer Shanghai Masters
David Ferrer celebrates his win over Andy Murray in the Shanghai MastersReuters

Novak Djokovic and Roger Federer notched up contrasting victories to reach the Shanghai Masters quarter-finals on Thursday while David Ferrer fought back from a set down to knock out Andy Murray.

World number one Djokovic laboured to a 6-3, 4-6, 6-4 victory over plucky Kazakh Mikhail Kukushkin who matched the Serb shot for shot for most of the match before being overpowered in the third set.

Two-time champion Djokovic broke Kukushkin for a 5-3 lead before closing out the first set but the Kazakh roared back into contention to stretch the contest to a decider.

Djokovic broke his opponent in the fifth game of the third set before extending his winning streak in China to 27 matches and seal a quarter-final clash with Ferrer.

"I congratulate him for fighting," Djokovic said of Kukushkin. "But I'm really glad to come out as the winner and stay mentally strong. That's why I won. I won because I fought my way through."

Ferrer overcame Murray 2-6, 6-1, 6-2 earlier on Thursday and the Spaniard will now replace the Briton in ninth spot in the race for the season-ending ATP World Tour Finals in London. There are five berths still up for grabs in the eight-man tournament.

Murray had little trouble in the first set and looked poised for a quarter-finals berth, but Ferrer staged a brilliant comeback, breaking the Briton twice to take the second and level the match.

There was no let up in the final set either as the Spaniard raced to a 5-2 lead and raised his arms in celebration when twice champion Murray buried a return into the net.

An in-form Ferrer would prove a difficult opponent, said Djokovic.

"We all know how competitive David is. To [beat] Murray is a big win for him. So I'm sure that he's confident.

"He runs. He's [been] one of the toughest competitors around for so many years. I expect another exhausting match."

Murray joined world number two Rafael Nadal, Australian Open champion Stanislas Wawrinka and US Open finalist Kei Nishikori in exiting the tournament before the quarterfinal stage.

The Briton said he had not made up his mind yet about where he would compete next as he bids to qualify for the ATP Finals for the seventh successive year.

Federer had little problem taming Spaniard Roberto Bautista Agut 6-4, 6-2 to set up a clash with Frenchman Julien Benneteau.

After squandering five break points, Federer finally broke his opponent in the 10th game to win the opening set and raced to a 5-2 lead in the second before sealing his victory when Bautista Agut's backhanded return crashed into the net.

Czech Tomas Berdych boosted his hopes of securing one of the five remaining places in London with a 6-3, 6-4 victory over Ivo Karlovic, who hit 19 aces in the third-round clash.

Berdych will replace US Open champion Marin Cilic, beaten by Karlovic in the opening round in Shanghai, in sixth place in the race to London if he beats Gilles Simon in the quarterfinals on Friday.