Los Blancos thought they had taken the lead after nine minutes when Gareth Bale turned home a cross from Karim Benzema, however celebrations were cut short as the former was flagged offside.
The hosts dominated possession for most of the first half, but they had to wait until the 29th minute for an opening at goal when Bale rifled a low strike just wide.
Ten minutes later, it was the visitors who broke the deadlock, with Marc Cardona lifting the ball over Keylor Navas to stun the home supporters.
Los Blancos had another goal disallowed shortly after the break as Benzema was deemed to be offside after 55 minutes.
Benzema was not to be denied four minutes later as the Frenchman nodded home a cross from Marco Asensio to restore parity.
It was all about the Frenchman, as he bagged the second goal for Los Blancos in the 81st minute, nodding home a cross from Toni Kroos.
Benzema could have a hat-trick in the latter stages, but the he struck the upright from close range in second-half stoppage time.
Nevertheless, Los Blancos were not made to pay for that as Eibar were unable to find an equaliser, with the encounter ending 2-1 in favour of the hosts.