Federer beat Robin Soderling 7-6 (2), 6-4.
Nadal had little difficulty in defeating his French opponent after reaching the last eight when Juan Martin del Potro withdrew from their third-round match Thursday.
Having broken Llodra for the first of four times in the opening game, Nadal didn't have to defend a single break point on serve as he won 25 of 30 first service points.
"I didn't think I would win like that," said Nadal, who also beat Llodra in their only prior meeting on the challenger circuit in 2003. "He's got a powerful serve and dangerous volley so it's hard to pass him but in the first set he committed some errors. Winning that first set gave me a lot of confidence."
Nadal stretched his clay-court winning streak to 36 matches as he goes for his second straight Madrid title in three seasons after splitting the last two finals against 2009 champion Federer.
Federer, meanwhile, was pushed by his Swedish opponent. Soderling saved three first set points before finally succumbing to the third-ranked Federer in a tiebreaker.
Soderling lost some of his momentum after that and netted on match point to confirm the attractive semifinal matchup.
"Conditions were tough today, I didn't know we could get such wind in a closed stadium. But I thought I played a great match from start to finish," said Federer, 8-15 overall against Nadal but 2-10 on clay.
"I'm excited, I'm playing Rafa here in the next round. I've beaten him here in the past, but it will obviously depend a lot on the day -- but he's the favorite on the clay," he said.
Sixth-seeded Ferrer put Djokovic under pressure in an entertaining match of acrobatic shots, with the Serb curling a shot down the line to break Ferrer for 3-2 in the final frame after the Spaniard had double-faulted on his advantage. Djokovic cruised to his 32nd straight win -- dating to December -- after converting his most important of five break points.
"It's David Ferrer. He never gives up," Djokovic said.
In women's play, Julia Goerges beat Anastasia Pavlyuchenkova 6-4, 6-2 for her 10th straight win to reach the semifinals. The German player, who defeated top-ranked Caroline Wozniacki in the third round, will face Victoria Azarenka, a 6-3, 3-6, 6-2 winner over Lucie Safarova.