Zinedine Zidane’s men kept their hopes of finishing second alive with a 2-1 win over their La Liga opponents at the Bernabeu.
Goals from Gareth Bale and Borja Mayoral sent Los Blancos on their way, before Darko Brasanac pulled a goal back for Leganes.
But at the end of added time, the away side had a fantastic chance to salvage a shock point.
In the dying seconds of the clash, Leganes were just about to shoot from around 20 yards out, as referee Ignacio Iglesias Villanueva decided to blow the whistle for full-time.
The visitors were incensed at the decision, and began protesting vehemently before leaving the turf.
The remonstrations saw Leganes captain Gabriel Appelt Peres sent off after the game had ended.
And fans were quick to take to Twitter to slam Villanueva’s decision.
One wrote: “Stupid referee. Should have let Leganes take the shot!”
While another angry supporter said: “The referee ended the game just as the Leganes player was about to pull a shot against Madrid. Terrible!”
And one added: “The referee has to take bribes to facilitate the victory of the Madridistas!”
Madrid now sit one point behind Atletico Madrid.
Meanwhile, Leganes remain in 15th place.