After an early exchange of breaks in the second set, Federer broke again and went on to complete a 6-2, 6-4 victory with an inside-out forehand winner on his first match point.
Federer will meet Juan Monaco in the last eight, after the unseeded Argentine survived two match points against American seventh seed Mardy Fish, who was forced to retire with a hamstring injury when leading 6-1, 6-7 (6/8), 2-1.
Djokovic overcame a first-set wobble to beat Serbian countryman Viktor Troicki 4-6, 6-3, 6-1.
The world number one was broken twice in the first set and folded on Troicki's first set point when he drove a backhand into the net.
Djokovic went 2-0 up in the second set, only for Troicki to level, but the top seed broke again to go 4-2 ahead with a cross-court backhand winner before levelling the match.
Troicki had lost his last nine encounters with Djokovic and the 15th seed's resistance broke apart in the third set, enabling the 2009 champion here to complete his comeback and take his place in the last eight.
'It was a difficult match,' said Djokovic, whose participation in the tournament had been threatened by the recurrence of a shoulder problem.
'I still wasn't maybe where I'd want to be with my shoulder, but I pulled out a good performance in the end.
'It's never easy to play someone you know well, who's your friend off the court, but a win is a win today.'
Djokovic will meet sixth seed Jo-Wilfried Tsonga, the 2008 champion, for a place in the semi-finals after the Frenchman overcame Italy's Andreas Seppi 6-3, 6-4.
In-form Murray made it 18 games unbeaten with an impressive 6-2, 6-2 win over Andy Roddick that took just 62 minutes and reduced the American number 13 seed to angrily smashing his racquet half-way through the second set.
'I started the match well, which is always important against Roddick because he plays his best when he's ahead and can put pressure on you,' said the Scot.
'As I broke him early on, I was able to dictate what happened and I played very well.'
Murray, the second seed, will now face Czech fifth seed and 2005 champion Tomas Berdych, who beat 11th-seeded Serbian Janko Tipsarevic in straight sets.
Tipsarevic's defeat means the line-up for the year-end ATP Tour Finals in London has now been finalised, with Berdych, Tsonga and Fish claiming the three places that were up for grabs at the start of the week.
Fish's withdrawal against Monaco means he faces a race against time to get fit for the start of the 20-27 November event, but he said he would be prepared to play regardless of the condition of his hamstring.
'I'll certainly play in London,' he said. 'There's no doubt about that. Even if it's torn, I'm still going to try to play.'
Spanish fourth seed David Ferrer continued his serene progress to the last eight by winning 6-3, 6-2 against Alexandr Dolgopolov of Ukraine.