Real Madrid go through after goalkeeper gaffe
In the 71st minute, the match was goalless and tense with big-spending Malaga, who lost 3-2 at the Bernabeu, needing to score only one to go through on the away goals rule when Real substitute Karim Benzema fired tamely straight at Caballero.
The Argentine keeper had made some impressive saves, but when he fell to his knees to collect, the ball squirmed between his legs and rolled over the line.
Jose Mourinho's men are likely to meet arch-rivals Barcelona in the last eight, with the European and Spanish champions visiting Osasuna on Thursday holding a 4-0 first-leg advantage.
Real will be joined in the quarter-finals by surprise qualifiers Real Mallorca and third tier Mirandes.
Mallorca scored four times in seven minutes during an astonishing comeback to knock out Real Sociedad 6-3 on aggregate earlier in the evening.
The Basques led 2-0 from the first leg in San Sebastian last week and took the lead in Mallorca after 16 minutes, while disgruntled home fans whistled their own side.
Mallorca's four-goal blitz started out of nowhere when Uruguayan Gonzalo Castro scored from a free-kick in the 34th.
Israel's Tomer Hemed cracked in a second two minutes later, Nunes headed in from a corner and seven breath-taking minutes after scoring his first, Castro racked up the fourth.
He caught out visiting keeper Enaut Zubikarai as he rolled the ball in front of him, nipping up from behind to steal it and roll the ball into the empty net.
The flood of goals continued after half-time with Alfaro and Hemed bagging his second before the hour mark, with a dazed Sociedad unable to react.
Mallorca, the 2003 Cup winners, will meet either Athletic Bilbao or third tier Albacete.
Mirandes claimed the scalp of a second La Liga side when they drew 1-1 at Racing Santander to progress 3-1 on aggregate.
Forward Pablo Infante, who scored one and set up the second in their 2-0 first leg victory, was the hero again for the lower league minnows.
Racing took the lead through Pedro Munitis in the first half, but a red card for their defender Bernardo took the wind out of their sails and Infante won and then netted a late penalty to put the Segunda B side through.
Mirandes, who knocked out Villarreal in the last round, will meet either Espanyol or second division Cordoba.