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.
|Wigglesworth´s career in Opta numbers as he breaks Premiership record|
|Ronaldo has nothing to prove, says Allegri|
|Federer shines as Europe hold narrow lead at Laver Cup|
|Astros, Yankees and Indians record dramatic wins|
|Pliskova too strong for Osaka in Tokyo final|
|Kyle Busch comes from behind to win again in Virginia|
|Dybala can play as a striker – Allegri|
|Pochettino never doubts ´special´ Kane|
|NASCAR results at Richmond: Kyle Busch comes from behind to win again in Virginia|
|McIlroy just worried about himself at Tour Championship|
|MLS Review: Atlanta stay clear of Red Bulls|
|Rose reminds everyone Woods has been here before|
|Cronk in doubt for Grand Final due to ´severe´ shoulder injury|
|Timberwolves sign Towns to extension|
|Hearn wants Wilder for Joshua, not ´un-entertaining´ Fury|
|Woods pleased with putting consistency|
|Ballon d´Or not a focus for Asensio|
|Man City star Mendy revels in Joshua triumph|
|Braves clinch first NL East title since 2013|
|I want Wilder, says Joshua|
|Inter must live on the edge to win, says jubilant Spalletti|
|Woods leads by three at Tour Championship|
|Bordeaux end Clermont´s perfect start, Zebo at double in Racing win|
|Lopetegui not worried about Courtois footwork|
|Joshua finds emphatic answer to Povetkin challenge|
|BREAKING NEWS: Brutal Joshua knocks out Povetkin in seventh round|
|Real Madrid can´t win 5-0 every week - Varane|
|Al Ahly 4 Horoya 0 (4-0 agg): Egyptian giants reach CAF Champions League semi-finals|
|Kings upset Warriors, Leinster batter Edinburgh|
|Son committed to Tottenham amid Bayern links|
|Simeone hails Atleti´s best LaLiga display of the season|
|Kovac: Bayern ´dominated´ Schalke in 2-0 win|
|Pochettino unimpressed with Tottenham´s tense finish|
|Campbell gains revenge as Price is halted by injury|
|Tottenham fatigue rumours are a myth, claims Rose|
|Widnes defiant after Super League relegation, Saints outclass Wolves|
|NFL must go back to college to eradicate the tie|
|Real Madrid 1 Espanyol 0: Asensio downs old club to earn narrow win|
|Sampdoria 0 Inter 1: Brozovic wins it late after VAR takes centre stage|
|Rudy takes blame for James goal in Bayern win|
|Tiger charges into four-shot lead|
|Players have given their lives to Burnley - Dyche|
|QPR 0 Norwich City 1: Pukki hits winner as hot streak continues|
|Nuno proud of Wolves character in Man United draw|
|Playing for England my dream, says in-form Maddison|
|Brighton and Hove Albion 1 Tottenham 2: Kane on target as Spurs issue firm response|
|Schalke 0 Bayern Munich 2: James and Lewandowski deliver another win|
|Getafe 0 Atletico Madrid 2: Lemar inspires routine win|
|Championship Review: Monk ruins Leeds´ unbeaten streak, McGinn screamer fails to save Villa|
|Bale benched for Real Madrid-Espanyol|
|Biggar fails to rescue Saints at Bath, Bristol and Wasps win|
|Zaha affected by back injury – Hodgson|
|Mourinho slams Manchester United attitude after Wolves stalemate|
|Herbert holds Portugal Masters advantage|
|Warnock blasts ´elementary´ Cardiff mistakes|
|Shaqiri substitution not easy for Klopp|
|Guardiola hopes for even more to come from Aguero|
|Fellaini accepts United closing gap to Premier League summit will be difficult|
|Klizan to face Thiem in St. Petersburg final, Bachinger shocks Nishikori|
|Klopp: Van Dijk injury not serious|
|Mourinho annoyed by Man Utd´s blunt attack in Wolves draw|
|Valverde not ready to consider Barca contract extension|
|Gattuso wary of wounded Atalanta as Higuain receives further advice|
|Burnley 4 Bournemouth 0: Rampant Clarets claim first Premier League win of the season|
|Crystal Palace 0 Newcastle United 0: Sakho misses sitter as Magpies remain winless|
|Cardiff City 0 Manchester City 5: Aguero celebrates new deal with goal in 300th game|
|Leicester City 3 Huddersfield Town 1: Comeback win eases pressure on Puel|
|Liverpool 3 Southampton 0: Salah ends goalless run as Reds make best Premier League start|
|Manchester United 1 Wolves 1: Moutinho stunner sees Red Devils falter at home again|
|Rashid, Hasan and Asghar fined by ICC|