Former UEFA Cup finalists Alaves were drawn against holders Barcelona in the last 32 of the King's Cup when the draw was made on Thursday.
The unheralded team from Vitoria in northern Spain went on a famous UEFA Cup run in the 2000/01 season when they eventually fell 5-4 to Liverpool in the final after a thrilling match that was decided by a golden goal in extra time.
Another Segunda B side, Alcoyano, will take on league champions Real Madrid.
The first legs are scheduled for October 31 with the return legs on November 28.
The draw for the following rounds was also made, up to the semi-finals where Real and Barca could meet as they both came out on the same side of the draw.
Barca knocked Real out in the quarter-finals 4-3 on aggregate last season.
The final is scheduled for May 18.