Barcelona, who have won the competition for the last three years, were held to a 2-2 draw at the Nou Camp by their last 16 opponents in La Liga on Saturday.
A youthful side fielded by Ernesto Valverde in the previous round put eight goals past Real Murcia, with last year’s champions now due to face a two-legged tie against Celta, with the first on January 3.
But while Barcelona came through their opening tie of the competition with relative ease, their rivals Real were not so comfortable.
Madrid suffered a scare against second-tier Fuenlabrada after they were held to a 2-2 draw at the Bernabeu last month, with the return of Gareth Bale needed to spark a comeback to progress with a 4-2 aggregate win.
Real have not won the competition since beating the holders in 2014, with a defeat by local rivals Atletico Madrid suffered at their Bernabeu home the season before.
Tuesday’s draw also paired last season’s semi finalists Atletico Madrid with third-division Lleida. Meanwhile, Formentera, another third-tier club, will play last-year’s losing finalist, Alaves.
The other pairings are: Cadiz vs. Sevilla; Leganes vs. Villarreal; Las Palmas vs. Valencia; and Espanyol vs. Levante.
The matches will be played during the first and second weeks of January.