Qatar-owned Malaga, who lie fourth in La Liga and who have cruised into the last-16 of the Champions League, were clinging on desperately at the end of their last-32 second leg with luck on their side.
Winger Chapi pounced on a loose ball after a free-kick to put the visitors ahead in the 37th minute and they sensed an upset towards the end of the second half.
Malaga defender Martin Demichelis diverted a goal-bound shot just wide of his own post and goalkeeper Carlos Kameni pushed another shot into the side-netting in the closing stages.
When the visitors did finally bundle in a second at a corner, it was ruled out for off-side and Manuel Pellegrini's side hung on to progress.
In other games, Real Madrid, Real Betis and Osasuna all moved in to the last 16, while second division Cordoba and Las Palmas claimed the scalps of top-flight side to progress.
Jose Mourinho gave four B team players a place in the starting line-up at the Bernabeu, including an official debut for winger Denis Cheryshev who made his first appearance for Fabio Capello's Russia in a friendly this month.
However, it was the established figures of Jose Callejon with two, and substitute Angel Di Maria with one, who grabbed late goals in a 3-0 victory, as Real triumphed 7-1 on aggregate over third-tier Alcoyano.
Cordoba upset Real Sociedad taking advantage of some poor defending to draw 2-2 at Anoeta and make the next round 4-2 on aggregate.
The Andalucian club's prize is likely to be a meeting with holders Barcelona, who host Alaves on Wednesday with a 3-0 first-leg advantage.
Las Palmas ousted Rayo 1-0 on aggregate grabbing a goalless draw in Vallecas after the home side had their goalkeeper sent off for the second time in the tie.
Real Betis, spurred on by their surprise 1-0 defeat of league champions Real on the weekend, overturned a first leg deficit against Valladolid to progress 3-1 on aggregate.
Osasuna joined them with a 2-0 home win over recently-relegated Sporting Gijon, giving them a 2-1 triumph.
- Sports & Recreation