Real Madrid will play Unionistas de Salamanca after a fairytale Copa del Rey draw on Tuesday while Barcelona were also handed third-tier opposition as they face Ibiza.
Barca won the cup four years in a row between 2015 and 2018 before losing 2-1 to Valencia in last year's final.
In the round of 32, 13-time European champions Madrid will face Unionistas, who were founded by a group of supporters in 2013 after UD Salamanca went out of business.
Unionistas entered the sixth tier of Spanish football in 2014, a few months after Real Madrid had just won the Champions League.
Madrid will play away, according to the rules of the competition, while Barcelona also face a trip to a team from Segunda B as they go up against Ibiza.
Ibiza beat Albacete on penalties in the previous round after the match finished 1-1 in normal time.
Atletico Madrid and Valencia, the other top-four finishers last season, also come into the Copa del Rey in this round.
Atletico will visit Cultural Leonesa while Valencia are away at Logrones. Logrones sit top of Segunda B's Group 2, three points ahead of Cultural Leonesa in second.
All the ties will be played between January 21 and 23.
Round of 32 fixtures:
Ibiza v Barcelona, Logrones v Valencia, Cultural Leonesa v Atletico Madrid, Unionistas de Salamanca v Real Madrid, Ebro CD v Leganes, Badajoz v Eibar, CF Badalona v Granada, Recreativo Huelva v Osasuna, Rayo Vallecano v Betis, Mirandese v Celta Vigo, Tenerife v Valladolid, Girona v Villarreal, Elche v Athletic Bilbao, Zaragoza v Mallorca, Seville v Levante, Real Sociedad v Espanyol
Independent journalism costs money. Support Times of Malta for the price of a coffee.Support Us