scored an injury-time winner as Real Madrid twice came from behind in a dramatic 3-2 victory over Levante on Saturday night.
Going into the match, Levante coach Joaquin Caparros had only won a single league match against Real from a possible 12 and his side looked capable of improving on that run as they took a 57th-minute lead through Baba Diawara.
Ramos levelled things before Nabil El Zhar restored the hosts' lead in the 86th minute, but Alvaro Morata and Ronaldo scored to give Real what looked like an unlikely win.
The hosts came into the fixture unbeaten in their last six and coach Joaquin Caparros made just the three changes from their win over Osasuna, as David Navarro, Jordi Xumetra and Andreas Ivanschitz returned.
Carlo Ancelotti continued his rotation policy as he made five changes from the Champions League win over Copenhagen in midweek.
Iker Casillas, Pepe, Marcelo, Dani Carvajal and Asier Illarramendi all dropped to the bench, as Diego Lopez, Alvaro Arbeloa, Ramos, Fabio Coentrao and Isco came into the side.
Levante started the match confidently and on-loan Sevilla forward Diawara tried to catch former team-mate Lopez off his line with an effort from around 35 yards, but the shot flew just over.
A minute before the break Lopez was the visitors' saviour as Baba hit a ferocious half-volley towards goal from range, but the keeper tipped it over the bar in dramatic fashion.
After cutting in from the right, Ronaldo struck the outside of the post in the 53rd minute with a left-footed shot and Levante made the most of their luck by opening the scoring.
Xumetra chipped a wonderful diagonal pass over the Madrid defence and Baba guided the ball past Lopez for only his second Liga goal since May 2012.
They were not ahead for long, however, as Real restored parity in the 61st minute. Di Maria whipped an inviting corner towards the back post and Ramos stuck a foot out to direct it past Keilor Navas and into the goal.
Ancelotti's side were piling on the pressure by the 70th minute and Marcelo should have given them the lead, but he somehow missed the target from eight yards out following an excellent cutback from substitute Alvaro Morata.
El Zhar looked to have won the match for Levante with four minutes left as he held off his marker before shooting past Lopez, but the hosts would end up disappointed.
Morata showed quick feet in the area before firing past Navas and then Ronaldo appeared in stoppage time to find the net via a wicked deflection, extending their unbeaten run away from home to 11 matches.