Real and Barcelona will face fourth-tier teams Deportivo Minera and Barbastro, respectively in the last 32 round of the Copa del Rey after the draw on Monday.
Barca, Madrid, defending champion Athletic Bilbao and runner-up Mallorca will start playing from this stage after skipping earlier rounds, having played in the Spanish Super Cup in January.
ALSO READ: Palmer scores twice from the spot as Chelsea beats Tottenham to move second on table
Barcelona, the record 31-time winner of this competition, faced Barbastro last season also, edging a 3-2 win.
Defending La Liga and Champions League champion Real Madrid will compete against Minera, which beat top-flight team Alaves in the previous round.
Cup-holder Athletic Bilbao will play Logrones, while Mallorca will clash against Pontevedra, which caused an upset after knocking out Villarreal.
Atletico Madrid will play third-tier team Marbella.
Full Copa del Rey round of 32 draw
Barbastro v Barcelona, Deportivo Minera v Real Madrid, Logrones v Athletic Bilbao, Pontevedra v Mallorca, Marbella v Atletico Madrid, Ponferradina v Real Sociedad, Ourense v Real Valladolid, Tenerife v Osasuna, Cartagena v Leganes, Elche v Las Palmas, Eldense v Valencia, Almeria v Sevilla, Racing Ferrol v Rayo Vallecano, Racing Santander v Celta Vigo, Huesca v Real Betis, Granada v Getafe