The Catalans came from behind to beat Ibiza thanks to two Antoine Griezmann goals in the second half of the teams' tie on Wednesday, the second in added time, and were paired with the relegation-threatened Madrid side in Friday's draw.
Madrid overcame Unionistas de Salamanca later on Wednesday and travel to Zaragoza in the one-off ties, which will be played between Tuesday and Thursday next week.
Defending champions Valencia are away to Cultural Leonesa, shock winners against Atletico Madrid after extra time on Thursday night.
Having knocking out Celta Vigo, Mirandes are at home to Sevilla and another Segunda side, Rayo Vallecano, face Villarreal after eliminating Real Betis on penalties on Thursday.
Tenerife, victors against Valladolid in the last round, are at home to Athletic Club, while Badajoz are rewarded with a tie against Granada after their win over Eibar this week.
All of the top-flight teams will play away against lower-level sides, as per the new Copa format, except for in the two ties involving LaLiga outfits, for which Barcelona and Real Sociedad were drawn first to face Leganes and Osasuna, respectively.
#CopaDelRey | ¡¡¡ESTE ES EL CUADRO DE LOS OCTAVOS DE FINAL DE LA COPA DEL REY!!!
¿Cuál es tu emparejamiento favorito?
➡️ Los partidos se disputarán los días 28, 29 y 30 de enero.
🔴 DIRECTO | https://t.co/tP49bAAmLX#LaCopaMola 🏆 pic.twitter.com/RFlM286boy— RFEF (@rfef)January 24, 2020
The Copa del Rey last-16 draw in full
Badajoz vs Granada
Cultural Leonesa vs Valencia
Tenerife vs Athletic Club
Zaragoza vs Real Madrid
Mirandés vs Sevilla
Rayo Vallecano vs Villarreal
Barcelona vs Leganés
Real Sociedad vs Osasuna