
The 21-year-old midfielder converted a cross from French left-back Theo Hernandez from the centre of the box.
That ended a run of three matches without victory for Zinedine Zidane’s struggling galaxy of stars, even though the likes of Cristiano Ronaldo, Gareth Bale, and Karim Benzema were left out.
Leganes were organized in defense and willing to launch counter-attacks, with the European champions struggling to cause them problems.
But Asensio’s late intervention gave Real a much-needed boost following last weekend’s 1-0 defeat at home to Villarreal that left them 18 points behind arch-rivals Barcelona in La Liga.
And unlike Barca, who lost 1-0 to their city rivals Espanyol on Wednesday, and Atletico Madrid, beaten 2-1 at home by Sevilla, Real are at least in charge of their quarterfinal tie in the competition that looks likely to offer them their best chance of silverware this season.
The second legs will be played next week.