MADRID — Roger Federer won the Madrid Open on Sunday against Tomas Berdych, showing that at least one tennis superstar could come to terms with the controversial blue clay used for the first time in this tournament.

Federer’s 3-6, 7-5, 7-5 victory allowed him to overtake Rafael Nadal as the world’s second-ranked player, behind Novak Djokovic. After losing earlier in the week in Madrid, both Nadal and Djokovic threatened not to return to the Spanish capital next year if the tournament was still played on the slippery blue clay.

Federer also claimed his third title in Madrid, as well as moving level with Nadal with a record 20 victories in Masters tournaments.

Federer came to Madrid after a five-week Caribbean holiday and came within two points of losing his opening match against Milos Raonic, a powerful Canadian. After that, however, the Swiss champion went from strength to strength, outpacing David Ferrer and Janko Tipsarevic on his way to the final.