Murray needs to beat Wawrinka tomorrow to defend his #2 spot.
As it stands, he and Federer are exactly level - both on points, and tournaments played. Not sure what the separator is, but going from reports Federer would be higher.
Doesn't mean much though - Murray defending 0 from Madrid, Federer defending 1000. Federer defending more in Rome as well.
Federer has 10 more points at the moment (live ranking). But it will be 100 after next week if Andy doesn't win today. He will need to reach the semis here to stay ahead of Federer until after Rome at least. If he loses in the quarters here, Federer will be back to #2 by the end of next week, again by 10 points. He has to reach R3 of Madrid to get it back, incase Fed wins it again. Otherwise it would come down to a tie and Fed would edge is because he has more points from mandatory events (7500 - 7480).
In short, it would be best if Andy could reach the semis here. Then Federer can't get #2 back until at least Rome (where he has to defend a semi).