The Swiss needed a lengthy injury time-out in the first set when he was barely moving, but returned to win the opening set tie-break and after a rain delay, and further treatment at the end of the third set, he found some fluency to reach the quarter-finals despite looking far from his best.
Top seed Djokovic, meanwhile, showcased his full armoury of shots as he sauntered into the quarter-finals with a 6-3 6-1 6-3 demolition of countryman Troicki.
The sight of Federer needing treatment is a rarity as the Swiss's body has seemed to defy medical belief over a largely injury-free career.
That is why it was such a shock to see him in obvious discomfort against Malisse on Centre Court.
During the first set he could do no more than push his serve into court while his forehand was half paced.
His future in the tournament looked as bleak as the looming clouds when he went off for treatment at 4-3 and then slipped a break down on his return.
He dug deep to break back when Malisse served for the opener and then rattled through the tie-break.
After another rain delay, when the roof was surprisingly left open, the third seed returned to move two sets ahead and although Malisse won the third and was a break up in the fourth, Federer survived to fight another day.
"I felt my back going at the beginning of first set and played for three or four games," Federer said.
"Maybe it was the two days off and the cold wind today but I managed to pull through in the end."
With grizzly grey skies encircling the All England Club, Serbia's Djokovic brushed aside compatriot Troicki 6-3 6-1 6-3 in his third consecutive match under the cover of the Centre Court roof.
Since its introduction in 2009, the structure has been used sparingly until this year when it has been hauled across come rain or shine both to block out the weather and ensure timely finishes for late-evening matches.
Djokovic has played all but his opening match with the giant mechanical lid in place and is now starting to get into the swing of things under cover.
"I have kind of got used to it," he told reporters.
"I find it a bit easier to return the serve. Obviously when you're playing on grass against a big server like Viktor, under these conditions you can neutralise the serve and get more into the rallies, so that was good for me...
"For somebody that plays all tournament outdoors and comes to the Centre Court for the first time and plays indoor in totally different conditions, it's quite a change. So you need time to adjust."
It was more than simple familiarity with the conditions that divided Djokovic from his countryman in what turned into a ruthless exhibition of shot-making and tennis artistry.
Djokovic came into the encounter on the back of an 11-match winning streak against his opponent and never looked like relinquishing the psychological edge as he broke decisively in the sixth game of the first set before closing it out.
The world number one was in no mood for hanging about in the second, breaking for the third time with a forehand volley to secure the set in just 24 minutes.
The screw had been firmly turned at this point and when Troicki sliced a backhand into the net to hand Djokovic a break in the third it was as good as over.
When Troicki passed up the opportunity of three break back points at 4-2 it was mere minutes before Djokovic was celebrating with a two-handed salute to the crowd.
As well as being Davis Cup partners, the two Serbs are good friends off court. The world number one, however, is not in the business of letting emotion cloud his on-court judgement.
"It's hard to express the emotions, you know, to celebrate or to be angry," he said.
"It's kind of difficult (to know) what to do and how to behave on the court when you're playing one of your best friends... So all these things are playing around with your emotions a little bit...
"But in the end we are professionals. (It) doesn't matter who is across the net, you want to win."
Djokovic will now be able to enjoy a rest day before facing a quarter-final against either Richard Gasquet or Florian Mayer who were still locked in battle when the rain brought an early end to all play away from Centre Court and its roof.