Javier Aguirre's side had won three of the four games ahead of the visit of Los Blancos but ultimately fell short of the three points required to overhaul Celta Vigo, who drew 0-0 with Espanyol.
Madrid, who sealed their first title since 2017 with victory over Villarreal on Thursday, went ahead through Sergio Ramos' early header before Bryan Gil equalised for the hosts.
Roger Assale set up a grandstand finish following Marco Asensio's strike shortly after the interval, but Leganes were ultimately unable to find a precious winner, with Madrid surviving a late VAR check for a possible penalty.