Things looked gloomy for the visitors when Fabio Cannavaro was sent off shortly after the interval and Patxi Punal put the home side ahead from the penalty spot with just eight minutes remaining.
But Arjen Robben equalised five minutes later and substitute Gonzalo Higuain struck with less than 60 seconds left on the clock to secure a second consecutive league title for Madrid.
Bernd Schuster's side began the day 11 points clear of second-placed Villarreal, but knew they would have to win this match to secure the title with three rounds to spare after Manuel Pellegrini's side defeated Getafe earlier on Sunday.
With victory needed to secure the title, Schuster kept faith with Javier Saviola up front alongside Raul and Arjen Robben.
But chances were at a premium early on as Osasuna defended stoutly.
The Pamplona-based side began the day in the bottom three and could ill afford another defeat after losing their last two matches.
The hosts began with their usual intensity, but failed to trouble their illustrious visitors in the opening stages.
And Madrid also struggled to find their rhythm on a rainy night in northern Spain.
However, the defending champions did begin to see more of the ball as the game progressed and created the first real chance of note more than a quarter of the way into the game.
With their intricate build-up play failing to bear fruit, the visitors tried a more direct approach and Mahamadou Diarra's blistering drive forced Ricardo into a fine one-handed save after 25 minutes.
But Real were unable to create any more decent opportunities in a poor first half.
Osasuna, meanwhile, grew in confidence as the game wore on, but appeared short of ideas in attack.
But Jose Angel Ziganda's side were given a huge boost just after the interval when Cannavaro was sent off following a mistimed challenge on Jaroslav Plasil.
It was the Italian's second bookable offence and he will now miss Wednesday's clash against Barcelona.
Despite their numerical disadvantage, Real looked the more likely to score and Wesley Sneijder came within inches of breaking the deadlock after 56 minutes when his lobbed effort beat Ricardo but rebounded off the crossbar to safety.
Sneijder also forced Ricardo into a fine save with a low free-kick later on, but the game appeared to be drifting towards a goalless draw in the latter stages until Osasuna won a penalty after 82 minutes when Gabriel Heinze handled a corner.
Punal sent Iker Casillas the wrong way to leave Real reeling, but the visitors produced a stunning comeback to clinch the title in the last five minutes.
Robben headed past Ricardo from close range on 87 minutes and Higuain completed the turnaround when he finished off a quicker counter-attack two minutes later by smashing an angled drive past the Osasuna goalkeeper to spark huge celebrations among the Real players and coaching staff.
The Madrid win means bitter rivals Barca, who earlier thrashed Valencia 6-0, will be forced to welcome the champions on to the pitch with a guard of honour when the two sides meet at the Bernabeu on Wednesday.
Osasuna, meanwhile, remain third from bottom and in danger of losing their top-flight status.