Gonzalo Higuain scored an 88th-minute winner as Real Madrid came from a goal down to sneak past a gutsy Deportivo La Coruna side.
The hosts, bottom of the Primera Division, took the attack to a slightly weakened Madrid side, with Luis Pizzi and Riki causing no amount of problems and it was the latter who broke the deadlock 10 minutes before the interval.
Depor had several chances to extend their lead but were made to rue some poor finishing when Kaka equalised in the 73rd minute, while Higuain sealed victory for the visitors two minutes from time.
Angel Di Maria was then given his marching orders in the 90th minute after picking up two bookings, but it mattered little to the result.
Jose Mourinho took the opportunity to rest several first-team stars ahead of Tuesday's Copa del Rey clash with Barcelona, while a Champions League last-16 second leg at Manchester United is looming large on the horizon.
The most notable absentee was Cristiano Ronaldo, who cut an imposing figure from the bench but could only watch on as his side were outplayed in the first half by the side coming into the game at the foot of the table.
Deportivo came out all guns blazing and Madrid goalkeeper Diego Lopez looked rather shaky, spilling Riki's fierce effort before defender Pepe cleared the danger.
Mourinho's men were lacking a cutting edge up front but the hosts looked vibrant and Pizzi narrowly missed the target having cut in from the right.
But Depor would break the deadlock in the 35th minute when Riki latched on to Pizzi's pass, cut in-between defensive duo Ricardo Carvalho and Pepe before beating Lopez at his near post.
Any thoughts the hosts would sit back and try to protect their lead were dismissed when Pizzi cut past Pepe before curling over Lopez only for full-back Marcelo to spare his team's blushes and head off the line.
Riki then twisted and turned past Carvalho, with his shot narrowly missing Lopez's right hand post while Madrid's goalkeeper also had to deny Portuguese winger Bruno Gama's fizzing strike before the interval.
Madrid were in all likelihood grateful for the half-time whistle to stop the Depor onslaught and they emerged energised when they came back out, with Callejon heading wide and Marcelo's goalbound strike blocked in the box.
Perhaps sensing an opening, Mourinho made a triple substitution as Ronaldo, Mesut Ozil and Sami Khedira entered the fray.
Madrid's star player made an immediate impact, slotting through for Higuain who thought he had drawn his side level when he netted, but the Argentinian had been flagged offside.
The visitors were certainly on top, however, and deservedly levelled matters when Kaka fired low into the net from just outside the area in the 73rd minute.
With the bit between their teeth, Madrid went in search of a winner and Ronaldo leapt in front of his marker but could only head narrowly wide.
But the Portugal international would play a key role to help his side snatch victory in the 88th minute, collecting the ball from Kaka and squaring for Higuain, who was left with the simplest of tap-ins.
Madrid's night was slightly soured by Di Maria's sending-off in the final minute, the winger perhaps harshly given his second booking for not advancing 10 yards at a set-piece.