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.