Looking to win the Cup for the first time since 2014, Madrid will travel to La Romareda next week to face Zaragoza, who were relegated from the top flight in 2013 and have not been back but did beat Mallorca in the last 32.
Zaragoza famously beat Madrid's 'Galacticos' in extra time in the 2004 final, with David Villa scoring one of their goals.
Zinedine Zidane's side beat third-tier side Unionistas de Salamanca on Wednesday, while Barcelona needed a late Antoine Griezmann goal to win 2-1 away to Ibiza.
The Catalans, who have won the Copa del Rey more times than any other club and reached the last six finals, will entertain a Leganes side sitting in the relegation zone in La Liga.
Meanwhile, third-tier Cultural Leonesa's reward for eliminating Atletico Madrid on Thursday is a home tie against the holders, Valencia.
Real Sociedad and Osasuna will meet in the only other tie between two top-flight teams.
Six clubs from the elite were eliminated by sides from lower divisions in the last 32.
Copa del Rey last-16 draw
Badajoz v Granada, Cultural Leonesa v Valencia, Tenerife v Athletic Bilbao, Zaragoza v Real Madrid, Mirandes v Sevilla, Rayo Vallecano v Villarreal, Barcelona v Leganes, Real Sociedad v Osasuna
- Ties to be played on January 28, 29, 30