Ronaldo had been engaged in a running battle with Valencia goalkeeper Diego Alves, and it was the custodian who had been winning.
He made several excellent saves to deny the Portugal striker and several more to keep Ronaldo's Real colleagues at bay.
It took just three minutes for Ronaldo to sting Alves' palms, and perhaps he should even have scored. Asier Illarramendi slipped in the forward, and he hammered a low effort toward goal, which the stopper parried.
Ronaldo had a similar chance later on in the first half, which again he belted toward goal after skinning Ricardo Costa, but Alves denied him.
The theme continued after the interval, with several opportunities going begging, including a free header Ronaldo spurned and a free-kick which was shovelled away.
Madrid knew that with a victory, they would be in a strong position in the title race after Barcelona drew with Getafe and Atletico tumbled away at Levante.
They started the game with a lot of energy, but Valencia withstood their attacks and began to come into it themselves. The opening goal was well taken by Jeremy Mathieu, who snuck in front of Raphael Varane and headed home.
It was poor defending from the youngster, playing in place of the rested Pepe.
Carlo Ancelotti decided to throw more coal on the fire to get Real Madrid going, with the ineffective Illarramendi making way for Angel Di Maria.
It seemed to help as Madrid looked more purposeful as the game continued and eventually equalised through Sergio Ramos. But mere minutes later, Valencia went back ahead through Dani Parejo.
Offered no help by either Gareth Bale or Karim Benzema, both of whom were extremely quiet throughout, Ronaldo ploughed a lone furrow.
It eventually paid dividends in stoppage time, just when you thought Madrid had messed up and put La Liga in the hands of their great enemies Barcelona and city rivals Atletico Madrid.
Di Maria pinged the cross in and Ronaldo back-heel-volleyed it past the helpless Alves.
It was a magnificent piece of quick thinking—almost as impressive as the glorious swivel Ronaldo pulled off while he made his connection. The ball hit the net, and the Santiago Bernabeu, which had been on tenterhooks, exploded. It was Ronaldo’s 50th goal this season and one of the finest he has scored.
Madrid are still not in the driving seat, because both Barcelona and Atletico can win the league if they win their remaining two games.
Atletico just need four points from their home game with Malaga and the trip to Camp Nou on the final day of the season.
Barcelona must win against Elche and then beat Diego Simeone’s side at home.
Real Madrid, however, have a game in hand, which is against Valladolid on Wednesday night. That will not be an easy undertaking, and it is followed by another tricky tie against Celta Vigo away.
Provided they win both those games, they will be looking for Barcelona to do them a favour against Atletico.
That would be an intriguing scenario if Tata Martino’s men knew that if they won their last game, they would be handing the title to Real Madrid.
Real Madrid’s players need not worry about that; for now, they have to concentrate on getting to the final day with a chance of lifting La Liga. If they play like they did on Sunday in either of the next two fixtures, then that’s not particularly likely.
Well, unless Ronaldo pops up once again to provide another moment of genius.