Marco Asensio struck a last-gasp winner as Real Madrid edged to a 1-0 win at Leganes in the first leg of their Copa del Rey quarter-final on Thursday.
Zinedine Zidane's men, 19 points behind Barcelona in LaLiga, had won one of their last five games in all competitions, amid reports the Frenchman could leave the club at the end of the season, and they looked set to be held at Butarque.
But after Leganes had shone on their first appearance at this stage of the competition, Asensio came up with a cute near-post finish from Theo Hernandez's cross to put Madrid in firm control of the tie.
Madrid were held at home by lower-tier clubs Numancia and Fuenlabrada in previous rounds after first-leg away wins and they struggled to respond to Saturday's 1-0 defeat at the hands of Villarreal, with Mateo Kovacic missing a golden first-half chance.
Jose Naranjo and Claudio Beauvue forced smart stops from Kiko Casilla and Marcos Llorente headed against his own crossbar, adding to the sense of injustice at Leganes' defeat.
Madrid were poor for large parts of the contest, but Asensio's dramatic impact may serve to ease the growing pressure on Zidane ahead of Wednesday's return leg at the Santiago Bernabeu.
GOLAZOOOOOOOOOO! What a goal!!! @TheoHernandez produced an excellent cross from the left and @marcoasensio10 expertly volleyed home, at the near-post, from iust outside the six-yard box!@CDLeganes 0-1 #RealMadrid#RMCopa | #HalaMadrid— Real Madrid C.F. (@realmadriden) January 18, 2018
Madrid were forced into an early change, introducing birthday boy Nacho at the back for the injured Jesus Vallejo, but Zidane's men made a flat start to the game and had to wait until the 23rd minute for a sight of goal, which Raphael Varane headed over the crossbar.
Javier Eraso rifled a long-range drive off-target as Leganes, on a four-game winning streak at home, found a foothold in midfield midway through the first half.
But Madrid should have taken the lead when Kovacic picked Ruben Perez's pocket 25 yards from goal, only for the Croatian to slide his shot tamely wide of the near post.
Gerard Gumbau got a vital touch to deflect Dani Carvajal's drive wide before Lucas Vazquez just missed Asensio's cross on the stroke of half-time.
Casilla had to react sharply to block a close-range Naranjo effort after 56 minutes, Diego Rico nutmegging Carvajal with a superb backheel to send the winger clear.
And Leganes came even closer to breaking the deadlock when Llorente could only direct a free-kick against the woodwork, with Casilla stranded.
Zidane brought on Luka Modric and Isco for more midfield control but Leganes substitute Nordin Amrabat had a more immediate impact, hooking a volley wide moments after his introduction.
With the game becoming stretched, Modric played Vazquez through but Nereo Champagne made a fine block, denying the Spain winger his fourth goal in the competition.
Casilla sharply palmed away a Beauvue volley destined to fly inside his left-hand post with 15 minutes to go and when Kovacic again finished meekly, Leganes looked to have held on.
It was not to be.
Clumsy for the most part, Theo had endured a poor game at left-back but his whipped delivery was perfect for Asensio to get in front of his man to flick home a vital goal for Zidane's Madrid.
21. Februar 2018
|Horsing around: Muller takes tips from equine companion|
|Lynn set for further assessment on dislocated shoulder|
|Ronaldo jets off for a break as Madrid head to Leganes|
|Bastareaud back in one of five France changes|
|Mistake to let Kroos leave Bayern for Madrid - Sammer|
|Short´s fifty and Agar´s spin seal deserved Australian tri-series win|
|Spalletti tips Ancelotti for Italy job|
|I can´t wait for retirement - Federer|
|Mendy on course for World Cup, says Deschamps|
|Man Utd on dismal knockout run, Roma have Shakhtar curse - Champions League in Opta numbers|
|Azpilicueta hoping for greater fortune at Camp Nou|
|Out of nothing he can score goals – Heynckes hails Muller|
|CONCACAF Champions League Review: Giovinco inspires Toronto, Tigres held|
|Steelers LB Shazier says he´s ´best linebacker ever´|
|Ranieri: I´ll quit Nantes if offered Italy job|
|Thiem keeps title defence on track, Monfils saves match point in Rio|
|Barcelona are great even without Neymar – Willian|
|Del Potro, Raonic progress at Delray Beach|
|Dolphins place franchise tag on Landry|
|Colts QB Luck ´extremely optimistic´ about shoulder rehab|
|Conte wants to see out Chelsea contract but has bags packed|
|A´s respond to Gruden´s belittling of Oakland|
|Yankees acquire Drury in three-team deal with Diamondbacks, Rays|
|Messi goal will give Barcelona more space at Camp Nou – Suarez|
|Serena Williams: I almost died|
|Conte defends ´incredible´ Christensen after Barcelona error|
|Bayern taking nothing for granted after 5-0 demolition – Heynckes|
20. Februar 2018
|Valverde: Barcelona away goal not definitive for progression|
|Muller & Robben bemoan poor first half despite Bayern rout|
|Ivashka sets up Wawrinka Marseille meeting|
|Chelsea close to a perfect game against Barcelona - Conte|
|Defending for 90 minutes at Barcelona a ´suicide mission´ - Fabregas|
|Championship Review: Villa miss chance to move into promotion places|
|Messi ends his Chelsea hoodoo|
|Texans release all-time leading tackler Brian Cushing|
|Chelsea 1 Barcelona 1: Messi breaks Blues hoodoo to leave tie in the balance|
|Bayern Munich 5 Besiktas 0: Two-goal Muller inspires emphatic win after Vida red|
|Woods and Stricker appointed USA Ryder Cup vice-captains|
|Wales must attack Sexton and Murray - Gatland|
|De Vrij confirms intention to leave Lazio on free transfer|
|Sanchez move down to Champions League frustration at Arsenal - Mourinho|
|Mourinho suggests Pogba is fit to face Sevilla|
|Clinical Kerber strolls past Strycova in Dubai|
|AFC Champions League Review: Hulk & Oscar lead Shanghai, Jeonbuk Motors hit six|
|Cech expects Ospina to start for Arsenal in EFL Cup final|
|Gueye signs new Everton deal until 2022|
|FA charges Man City and Wigan for failing to control players|
|Aguero faces no action over Wigan fan incident|
|Martin released by Buccaneers|
|Las Palmas get green light to sign Viera replacement amid Nasri talk|
|De Kock, De Villiers & Du Plessis looking to Australia Tests|
|FA issues West Ham with anti-doping charge|
|Florenzi a doubt to face Shakhtar, confirms Roma´s Di Francesco|
|Maybe we ´lock him up or tie him up´ – Montella ponders how to stop Sanchez|
|French rugby crisis could last a long time - Magne|
|Pogba and Ibrahimovic train with Man Utd ahead of Sevilla tie|
|Zidane hints at resting Ronaldo for Real Madrid´s trip to Leganes|
|Biggar, Halfpenny and Williams return to Wales´ starting XV|
|Modric adds to Real Madrid injury worries|
|Braehmer pulls out of Super Series semi-final|
|Wolfsburg turn to Labbadia in fight for Bundesliga survival|
|Hales follows Rashid in signing white-ball deal|
|Wigan to investigate pitch invasion after win over Manchester City|
|Drogba ´couldn´t be more proud´ as son signs for Guingamp|
|Stones making no excuses for shock Wigan defeat|
|Bellugi scathing of Inter form and transfer policy|
|Ringrose could make Six Nations impact after comeback|
|Rakitic: I´ve not seen Messi in the gym this often|
|Winter Olympics 2018: Slovenian ice hockey star Jeglic sent home after positive doping test|
|Sevilla v Manchester United: Montella and Mourinho unified in pursuit of identity|