Federer delivered 15 aces while being tested by Mayer. The Swiss standout hasn't won a title yet this season while dealing with back and knee injuries.
Federer will have to get past third-seeded Dominic Thiem to reach the title match. The Austrian recovered from a shaky start to defeat Russia's Mikhail Youzhny 3-6, 6-4, 7-5.
Seventh-seeded Philipp Kohlschreiber of Germany also reached the semifinals by defeating Radek Stepanek of the Czech Republic 6-4, 7-5. Kohlschreiber will face Argentina's Juan Martin del Potro, who upset fourth-seeded Gilles Simon of France 6-7 (3), 6-3, 6-0.
Muller, of Luxembourg, used 17 aces in his upset of the Spaniard. Muller will face third-seeded Ivo Karlovic in the semifinals.
Karlovic, of Croatia, was a straight-set 6-3, 6-4 winner over France's Adrian Mannarino. Fifth-seeded Sam Querrey cruised past fellow American Stefan Kozlov 6-3, 6-0 and will face eighth-seeded Nicolas Mahut of France in the other semifinal. Mahut stunned second-seeded Australian Bernard Tomic 6-7 (5), 6-4, 6-2.
In women's play, top-seeded Belinda Bencic had to fight off fellow Switzerland native Viktorija Golubic to post a 7-6 (6), 7-6 (2) victory to reach the semifinals.
After escaping against the qualifier, Benecic will face third-seeded Kristina Mladenovic of France. Mladenovic defeated Belgium qualifier Elise Mertens 7-5, 6-3.
Sixth-seeded American Coco Vandeweghe beat Russia's Evgeniya Rodina 6-2, 6-2 and will face American Madison Brengle in the other semifinal. Brengle was a 7-5, 6-4 winner over Ukraine's Kateryna Kozlova.