Real now sit just four points behind Atletico in the standings, while Eibar remain in eighth despite a valiant effort against the defending champions.
Eibar started the game at the Ipurua Municipal Stadium on the front foot, with former Real Madrid midfielder Pedro Leon sending a free header over the crossbar from 12 yards as early as the second minute.
The home side continued to control the early stages of the fixture and in the 19th minute, Kike Garcia and Takashi Inui linked up before Garcia saw his 25-yard curler tipped behind for a corner by Keylor Navas.
Joan Jordan also squandered a headed opportunity after meeting Leon's outswinging free kick but as the first half progressed, Real began to stamp their authority on the contest.
Gareth Bale was denied by a fine block from Marko Dmitrovic but moments later, the visitors went ahead when Ronaldo collected Luka Modric's exquisite pass over the top of the defence before finding the bottom corner from 12 yards.
Just before the break, Ronaldo forced a stunning stop out of Dmitrovic after his 20-yard strike was deflected on goal, with Sergio Ramos then sending a free header wide of the post from no more than 10 yards out.
A second goal would have led to Real being in full control of the contest but within six minutes of the restart, Eibar were back on level terms as Ramis sent a header into the net from 10 yards after meeting Leon's corner.
Eibar's leveller led to Real placing more emphasis on regaining their advantage and it soon became a game of attack versus defence as the hosts attempted to keep hold of a share of the spoils.
Modric should have scored from 12 yards but after running into the penalty area, the Croatian dragged his effort wide of the far post, while Ronaldo also missed out inside the 18-yard box with Dmitrovic somehow sticking out a hand to divert his strike wide of the post.
From the resulting corner, Bale got above the Eibar defence, only to divert his glancing header wide of the post, but the opportunity suggested that the visitors were starting to up the tempo.
However, it was Eibar who began to rally as the match entered the final quarter of an hour, with Inui sending a header over the crossbar and substitute Paulo Oliveira seeing an overhead kick go straight at Navas.
Kike Garcia was also provided with an opportunity down the left-hand side of the penalty area but the forward rushed his shot, which went wide of the near post from no more than 12 yards out.
Real were on the back foot but it did not stop the visitors regaining the lead with six minutes remaining, with Ronaldo sending a header into the roof of the net from eight yards after meeting Dani Carvajal's cross.
Eibar attempted to get back into the match for the second time, but Real were able to hold on to an important win which effectively keeps the club in the race for the runners-up spot in Spain's top flight.
EIBAR (4-2-3-1): Dmitrovic; Capa, Ramis (Oliveira, 67'), Arbilla, Cote; D.Garcia, Escalante (Diop, 85'), Leon, Jordan, Inui (Charles, 87'); Kike
REAL MADRID (4-4-2): Navas; Carvajal, Varane (Nacho, 28'), Ramos, Marcelo; Casemiro, Kroos (Vazquez, 71'), Modric, Isco (Benzema, 71'); Bale, Ronaldo