Real will take on the Galicians of Celta Vigo and Barca will face Basque outfit Real Sociedad.
In the other ties, Atletico Madrid will meet a modest Eibar side who have reached the last eight for the first time while second division survivors Alcorcon go up against Alaves.
Real Madrid will take on Celta next Wednesday after putting out Sevilla, conquerors of Valencia.
Barcelona got past Athletic Bilbao after turning around a 2-1 first-leg deficit.
The first-leg games are on January 18 with the returns on January 25.
Draw:
Real Sociedad v Barcelona
Alcorcon v Alaves
Atletico Madrid v Eibar
Real Madrid v Celta
Download our app and read this and other great stories on the move. Available for Android and iOS.