Second seed Federer, who turns 38 next month, won 7-6 (3), 1-6, 6-3, 6-4 against the Spanish in their first meeting here since the 2008 final when Nadal lifted the trophy.
Federer will fight for the title against defending champion Novak Djokovic in Sunday's final. Four-time champion Djokovic defeated Spain's Roberto Bautista Agut 6-2, 4-6, 6-3, 6-2 earlier.
Two-time winner Nadal, who crushed Federer in straight sets in last month's French Open semifinal, still leads the head-to-head 24-16.
This year's final will be the first major final between two of the "Big Three" since Djokovic beat Federer in the 2015 Wimbledon final.