Los Blancos had slumped to defeat away to CSKA Moscow in the Champions League on Tuesday night, which came on the back of a goalless draw at home in the Madrid derby and a 3-0 loss at Sevilla.
Despite recalling the likes of captain Sergio Ramos, Luka Modric, goalkeeper Thibaut Courtois and fit-again Gareth Bale, Real again lacked a cutting edge in the final third.
Despite conceding large spells of possession, Alaves stuck in with their illustrious visitors and were rewarded when substitute Garcia headed in from close range during the fifth minute of added time.
Real remain second, level with leaders Barcelona but having played a match more, while Alaves are third, also on 14 points.
Former Spain boss Lopetegui expected a response from his side following their midweek loss and initially Real produced a positive start.
After nine minutes, Karim Benzema saw his goalbound header from full-back Alvaro Odriozola’s cross hacked off the line by Alaves defender Ximo Navarro.
At the other end, Jony just failed to get on the end of a long pass upfield which would have put him clear.
As the half-hour mark approached, Bale, who had missed the trip to Moscow because of a minor groin problem, crashed a 25-yard free-kick straight into the wall.
Los Blancos saw plenty of possession during the closing stages of the first half but failed to find a telling pass in the final third as Alaves defended resolutely.
Lopetegui made a change for the second half, sending on Mariano to freshen up the attack in place of Benzema.
Jony set up Ibai Gomez with an early chance, but Real defender Raphael Varane was alert to clear before Ruben Duarte tested Courtois with a long-range effort.
With 20 minutes left, Bale cut in from the right wing and sent an angled shot over the far corner.
Alaves had a great chance on the counter as Jony broke down the left, but, after charging into the penalty area, he could only drag a low shot wide.
Bale again tested the Alaves keeper with a free-kick from distance, which Fernando Pacheco gathered at the second attempt.
As the clock ticked down, Nacho sent in a cross from the left, which Mariano headed over.
There was, though, still enough time left for the home side to snatch all three points when Garcia bravely nodded in from close range after Ruben Sobrino’s effort had been saved by Courtois.