Federer clinched the 7-6(5) 7-6(4) victory on his third match point shortly after Wawrinka fell 4-6 6-2 6-1 to 16th-seeded German teenager Alexander Zverev.
Bautista Agut played the match of his life, hitting the ball deep with relentless precision in an effort to keep Federer pinned to the baseline, giving the 18-times grand slam champion everything he could handle.
But Federer's class proved the difference in the tiebreaks as he improved to 6-0 lifetime against Agut and advanced to a quarter-final match against Czech 10th seed Tomas Berdych.
Wawrinka, who turned 32 on Tuesday, lost to Federer in the Indian Wells final nine days ago and was denied a chance of setting up a possible rematch in Miami.
A day after saving three match points and beating John Isner, the 19-year-old Zverev dominated the final two sets against Wawrinka, breaking twice in the second and three times.
Zverev will now face Nick Kyrgios following the Australian's 7-6 6-3 victory over David Goffin.
All the top seeds had competitive matches on Tuesday, with Japanese second seed Kei Nishikori also taken to three sets before ousting Federico Delbonis of Argentina 6-3 4-6 6-3.
Fifth seed Rafa Nadal won in straight sets, but also had to be near his best to beat Frenchman Nicolas Mahut 6-4 7-6(4).
Next up for Nadal is American Jack Sock, while Nishikori meets Italian Fabio Fognini.
Read the original article on Eurosport: Federer and Nadal reach Miami quarters as Wawrinka falls