Djokovic beat Stanislas Wawrinka 6-1, 6-4, and edged del Potro 6-3, 4-6, 6-3.
Federer earned his first victory over a top-10 player since January, when he outlasted Jo-Wilfried Tsonga in the quarterfinals of the Australian Open.
"That's definitely good for my confidence, because those are the kind of wins I need right now," Federer said. "I'm happy now I won against a top-10 again, especially just before London where I will have to play against three top-10 players in a row."
Federer lost to del Potro in last weekend's Swiss Indoors final, but the 17-time Grand Slam champion played nearly flawless tennis in the first set, making 17 winners and only four unforced errors.
Del Potro fought back in the second set, saving a break point in the opening game before converting his second break chance at 5-4 to level the match when the fifth-seeded Federer netted a forehand.
In the deciding set, del Potro sent a forehand into the net to drop serve at 3-3 and Federer won the match when the Argentine hit a forehand long.
Djokovic, who saved all six break points he faced, won 13 of 19 points at the net.
"Coming to the net is one of the improvements that I had recently," Djokovic said. "It didn't click so fast, trust me. I had to work and put in many, many hours on the practice court that you guys don't see."
Wawrinka lost five-setters against Djokovic at the Australian Open and the US Open this year.
"When he plays that good it's very difficult, especially on this surface where he's the best, I believe," Wawrinka said.
Nadal improved his record against Gasquet to 12-0 despite a crowd cheering loudly for the only Frenchman left in the draw.
The Spaniard, who is seeking a record sixth Masters title in a single season, broke for a 4-3 lead with a crosscourt backhand return winner.
Gasquet struggled with his one-handed backhand against Nadal's powerful groundstrokes. The US Open champion went a set up when Gasquet made a backhand error.
Nadal took a 4-0 lead in the second set and finished off Gasquet with a forehand winner down the line.
The eight quarterfinalists are in the eight-man ATP World Tour Finals next week in London.