Ramos went off on minute 73 before Ronaldo had scored his second goal to give Real Madrid all three points in a 2-1 win.
Real move four points behind second-placed Atletico Madrid, who can restore that gap to seven with a win over Celta Vigo on Sunday.
Eibar responded well to going a goal behind, though, and restored parity just minutes into the second half, with Ivan Ramis losing Sergio Ramos from a corner kick to head past the helpless Keylor Navas.
But Ronaldo put his team back on top in the 84th minute.
With clashes to come early next month against Atletico Madrid and then the Champions League quarter-final, an argument could have been made to rest the club legend yet again, for the third time in five league matches - preserving his premium match sharpness.
Ramos addressed the situation in an Instagram post after the game, accompanying a picture of himself celebrating a goal with Ronaldo alongside the caption: "Nature calls".
Sergio Ramos simply couldn't hold out for full time when his stomach began urging him to visit the bathroom late on in Real Madrid's La Liga clash with Eibar.
Madrid was six minutes away from dropping points when Ronaldo came through with a powerful header to send in Dani Carvajal's cross and grab victory.
"He's from another planet", Madrid manager Zinedine Zidane said after the match. "The numbers speak for themselves".
A sloppy pass out from the back by Anaitz Arbilla conceded possession to Modric, who quickly picked out Ronaldo.
Madrid defender Raphael Varane was substituted in the 26th after a blow to the head.
"The important now is to keep picking up three points in every game".
Shortly after, the visitors had the lead - Modric finding Ronaldo with a remarkable lofted pass using the outside of his foot and the forward finishing the chance with aplomb.