The Swiss great will play in the Madrid Open before tackling Roland Garros after deciding to end his clay-court absence this season.
Roger Federer will play in the Madrid Open in May as part of his clay-court comeback.
Federer has not played in the clay-court season since 2016, but the 20-time grand slam champion revealed after his Australian Open exit that he plans to grace the red surface this year.
The former world number one has confirmed he will return to the Caja Mágica as he steps up his preparation for what is set to be his first French Open appearance since 2015.
"Federer is one of the best players of all time, it's no secret," said Madrid Open director Feliciano López, who is relishing a stellar line-up featuring Federer's great rivals Novak Djokovic and Rafael Nadal.
"We are happy because his return to Madrid is a gift to the tournament, but above all the fans will be able to see a unique player in the Caja Mágica. Having the Swiss player back on clay with Djokovic and Nadal is going to be unmissable."
Honorary Madrid Open president Manolo Santana, said: "Roger's presence in the Caja Magica will make this year's Madrid Open special.
"It doesn't matter that he's 37 because he still has that unmistakable class; the innate talent that has made him one of the best of all time. Being able to enjoy his tennis is something that no fan of the sport should miss."
Federer has won the Madrid Open three times, his most recent success in the Spanish capital coming in 2012. The Swiss great will use the Masters 1000 tournament as preparation for another assualy on Roland Garros, where he last appeared in 2015 and reached the quarter-finals.