Los Blancos beat Numancia in the round of 16, and given their woeful performance in La Liga, the cup could offer them their best route to silverware.
Leganes have been steady in the top flight of Spanish football, comfortably clear of the relegation dogfight in mid-table.
Here is how you can watch the opening leg of the tie:
Date: Thursday, Jan. 18
Time: 8:30 p.m. (GMT)/ 3:30 p.m. (ET)
TV: beIN Sports (U.S.)
The long-term tenure of Real manager Zinedine Zidane remains questionable after a poor start to the campaign.
Real travel to the outskirts of the capital city for their first-leg encounter against the Cucumber Growers, as the Spanish cup reaches its crucial rounds.
The hosts' Estadio Municipal de Butarque ground remains one of the smallest in top-flight European football, and an intimate crowd will hope to add weight to the cause.
Real progressed 5-2 on aggregate as they dumped Numancia out, but their next opponent will be more resilient than their recent challengers from the Segunda Division.
Zidane's men have failed to sparkle this season, and the 19-point gap to La Liga leaders Barcelona tells its own tale.
The club have stopped scoring goals in the prolific manner of previous years, and the time will soon come for president Florentino Perez to act.
However, the cup offers the giants respite and allows Zidane to continue the blooding of fresh talent.
Lucas Vazquez scored twice in the second leg against Numancia at the Bernabeu Stadium in the previous round, proving Real have depth to tap into.
Leganes have won three of their last six in all competitions, and they will know the time is right to hit Real where it hurts.
The first leg is vital in the minnows' hopes of progressing, and they will desire a weakened side to face them.
It is likely Cristiano Ronaldo will be given the night off if Zidane follows his usual selection script for the cup, giving the hosts a slim chance of a dramatic shock.