Djokovic beat Sergiy Stakhovsky of Ukraine 7-6 (5), 6-3, while Federer defeated Feliciano Lopez of Spain 7-5, 6-3.
Andy Murray of Britain also reached the final eight with a 6-3, 6-4 win over Marco Chiudinelli of Switzerland, as did Russia's Mikhail Youzhny, who beat American Mardy Fish 6-2, 7-6 (0).
The top-ranked Djokovic, seeking his fourth consecutive title in Dubai, wasn't at his best for a second straight match after struggling against Cedrik-Marcel Stebe in the opening round. The Serb hadn't played in a tournament since winning the Australian Open.
Stakhovsky was 4-3 up in the first-set tiebreaker, but two costly unforced errors let Djokovic off the hook, and he took the set when the Ukrainian hit a forehand long.
Djokovic was down 3-1 in the second but won five straight games to set up an all-Serbian match against Janko Tipsarevic, who beat Flavio Cipolla of Italy 6-7 (2), 6-1, 6-1.
"The difference between the top players and maybe the lower-ranked players is actually those moments,'' Djokovic said of his comeback. "And managing to keep your composure and cope with the pressure and just focus, have an extra focus, mental strength.''
Federer broke Lopez in the final game to end a tight opening set. The second set was more routine, with the Swiss breaking the Spaniard for a 5-3 lead before closing the match with a volley from the net.
Federer, who was beaten in the Dubai final last year by Djokovic, is going for his fifth title and second in 2012 after winning in Rotterdam.
"It was tough getting used to his serve early on. I wasn't having many looks - he was serving aces left and right,'' said Federer, who won 92 percent of his points on first serve.
In a reprise of the 2007 final, Federer will next face Youzhny, whom he has never lost to in 11 meetings.
Fish's loss was another setback to what has already been a disappointing start to 2012.
After replacing Andy Roddick as the top-ranked American last year, Fish has struggled. He lost in the second round of the Australian Open and was beaten by 388th-ranked Albano Olivetti in the Marseille quarterfinals last week. He did, however, help the United States rout Switzerland 5-0 in the Davis Cup.
"It's no disgrace to lose to someone like him, but it's frustrating to lose,'' Fish said. "I had a rough trip, last couple of matches did sting a little bit going into Indian Wells and Miami.''
Murray broke Chiudinelli early in the first set and moved him around the court with ease. The second set was closer as both players held serve for the first eight games. But Murray broke to lead 5-4, winning the match on a powerful serve Chiudinelli couldn't return.
Murray will play fifth-seeded Tomas Berdych, who beat Lukas Lacko of Slovakia 6-1, 6-2.
In the late match, fourth-seeded Jo-Wilfried Tsonga beat Lukas Rosol of the Czech Republic 6-3, 6-4. He will play eighth-seeded Juan Martin del Potro, who beat Andrey Golubev of Kazakhstan 6-4, 6-2.