Already 3-0 ahead from the first leg, coach Zinedine Zidane could afford to rest his superstars with one eye on La Liga, where they are 16 points behind Barcelona, and the Champions League last 16 with a clash against Paris Saint- Germain next month.
However, they were far from convincing at the Bernabeu.
Lucas Vazquez scored both of Real's goals on Wednesday after the 11th and 59th minutes.
But on both occasions, their modest visitors fought back thanks to a brace from Guillermo on the stroke of half-time and then after 82 minutes.
Numancia ended the game with 10 men after captain Dani Calvo was red-carded in the dying moments. Leganes, a modest club from the Madrid suburbs, reached the quarter-finals of the Copa del Rey for the first time in their 89-year existence.
Despite losing 2-1 at Villarreal, who are currently sixth in La Liga, Leganes progressed on away goals having won the first leg 1-0.
Moroccan international Nabil El Zhar scored the crucial away goal for mid-table Leganes on the half-hour mark.
In the night's other early second leg tie, last season's runners-up Alaves downed third division Formentera 2-0 for a 5-1 aggregate win.
On Thursday, three-time defending champions Barcelona host Celta Vigo with the two sides locked at 1-1.