Real Madrid 3 - 1 Osasuna
Osasuna went ahead through Javad Nekounam's 20th-minute header but Madrid fought back through second-half goals by Sergio Ramos, Gonzalo Higuain and Arjen Robben.
But the win was soured by two terrible refereeing decisions that saw the unfortunate Juanfran sent off when Alfonso Perez Burrull incorrectly booked him twice for diving when he should have awarded penalties.
The first booking came on 13 minutes when Fernando Gago clumsily slid in on the Osasuna winger, taking him down first with his thigh and then with a trailing leg.
Gago got nowhere near the ball and it should have been a spot-kick.
The second decision was yet more woeful. With less than 10 minutes remaining and with Madrid leading 2-1, Pepe clearly trod on Juanfran's foot as he burst into the box and prepared to pull the trigger.
But inexplicably Burrull blew for simulation and sent the distraught Juanfran to an early bath.
The defeat was even more frustrating for Osasuna because two of the goals came from goalkeeping howlers by Roberto.
Sergio Ramos equalised four minutes after the second-half restart when he surged forward from right-back and released a low drive that Roberto allowed to squirm through his hands.
Higuain put the hosts in front with a tap-in after a clever give-and-go with Robben while, in injury-time, Robben added a gloss on the win when his own daisy-cutter was mis-handled by the poor Roberto.
The result puts Madrid in second place, level on points with Sevilla but with a superior goal difference, while Osasuna remain at the foot of the standings.