The Scot played well in Spain, but by failing to successfully defend his title, he drops below Federer ahead of the Italian Open this week.
Djokovic, an 11-time major champion, retains his massive lead on his closest challengers at the top of the rankings after claiming a record 29th Masters title.
Australian youngster Nick Kyrgios moves back into the top 20 thanks to his run to the quarter-finals in Madrid.