Real Madrid will face fourth-tier club Cacereno in the Copa del Rey's round of 32 in early January.
Cacereno produced the biggest shock of the second round when beating LaLiga side Girona 2-1 on Thursday, with the Catalans becoming the first top-flight side to be knockout of this season's competition.
The Segunda Division RFEF side have been rewarded for that success with a dream duel with Real Madrid, who will travel to Caceres for the game.
For Cacereno, such a draw will provide a huge boost financially.
Club president Carlos Ordonez was quoted by AS as saying: "It is the maximum lottery that a man from Caceres could win. It has been a continuum of messages, calls, WhatsApps...
"It is the greatest prize that could be given to us. It is an economic boost that for a club like ours is super important. Real Madrid hasn't come to Extremadura for a long time and it's a prize for all Extremadurans."
Madrid only entered the competition in Friday's draw, with Barcelona joining them.
The Blaugrana are set to face third-tier side Intercity of San Juan de Alicante, who have had a fairly rapid ascension to the Primera Division RFEF since their 2017 foundation on the sixth level of the Spanish football ladder.
Atletico Madrid will go to Real Oviedo, while holders Real Betis begin their campaign at Ibiza Islas Pitiusas.
Real Sociedad and Sevilla were drawn with third-tier opponents in Logrones and Linares Deportivo, respectively.
Matches are due to take place between January 3 and 5, with exact kick-off dates and times to be confirmed in due course.
Full third-round draw:
Ibiza Islas Pitiusas v Real Betis
Cacereno v Real Madrid
Intercity v Barcelona
La Nucia v Valencia
Logrones v Real Sociedad
Eldense v Athletic Bilbao
Pontevedra v Mallorca
Gimnastic Tarragona v Osasuna
Linares Deportivo v Sevilla
Ceuta v Elche
Deportivo Alaves v Real Valladolid
Levante v Getafe
Real Oviedo v Atletico Madrid
Cartagena v Villarreal
Sporting Gijon v Rayo Vallecano
Espanyol v Celta Vigo