Lucas Perez scored a fifth-minute penalty at Alfredo di Stefano stadium and Joselu added a second just after half-time following an awful mistake by goalkeeper Thibaut Courtois.
Casemiro gave Real a lifeline on 86 minutes but Alaves held on for a victory that lifted them up to ninth. Madrid remain in fourth place and six points behind Real Sociedad and Diego Simeone's Atletico.
After a minute's silence in honour of Diego Maradona, in keeping with the poignant tributes around Spain this weekend following the death of the Argentine legend, Real soon fell behind when Nacho handled at a corner.
Perez powered the spot-kick beyond Courtois to give Alaves the lead, and the forward should have struck a second when he was played clean through, his attempted chip superbly swatted aside by the Real 'keeper.
Madrid's night went from bad to worse when Eden Hazard was forced off on 28 minutes after taking a knock, the latest in a long list of injury setbacks for the Belgium star.
While a terrific double save by Fernando Pacheco denied Toni Kroos, a howler from Courtois presented Joselu with the second goal on 49 minutes when a wayward pass went straight to the forward who steered home from 30 yards.
Mariano Diaz's header was cleared off the line before Casemiro tapped in from close range after Pacheco kept out Vinicius Junior's effort, but Alaves clung on as Isco clipped the bar with the final kick.
Earlier in the day, Atletico edged a tight contest at Valencia 1-0 that stretched their unbeaten league run to 25 matches.
They stay second but are equal on 23 points with Sociedad with a game in hand thanks to Toni Lato's own goal 11 minutes from time.
Stingy Atletico have conceded just twice in their nine league matches so far this season and have only scored two less than La Liga top scorers Sociedad, who host third-placed Villarreal on Sunday.
"We have made huge progress since April, since that wonderful match at Liverpool," said Simeone, referring to the Champions League last 16 tie his team won 4-2 on aggregate.
"The return to La Liga (after the first lockdown) was very good and the team was already starting to show encouraging signs. This is the result of the progression of all of the players."
Simeone offered a round of applause to his former teammate and friend Maradona while teams held a minute's silence before kick-off.
Fellow traditional title rivals Barcelona are 12 points back in 14th place, although they host Osasuna in Sunday's early match and will still have two games in hand on Sociedad come the end of the weekend.
Sevilla honour Maradona
Atletico will face European champions Bayern Munich in the Champions League on Tuesday hoping to reach the knockout stages with a match to spare.
They would join Sevilla, who qualified for the last 16 on Tuesday and are up to fifth in La Liga after a 1-0 win at relegation strugglers Huesca.
Youssef En-Nesyri won the points for Sevilla after nipping in at the near post to tap in Lucas Ocampos' low pull-back with seven minutes remaining in a match dominated by the reigning Europa League champions.
Julen Lopetegui's side are one point behind Real Madrid as they chase a top four spot and a return to Europe's elite competition for next season.
There was also held a tribute to former Sevilla player Maradona, who signed for the Andalusian club in 1992 after the end of a long drugs ban which hastened his exit from Napoli. He stayed one season before returning to Argentina with Newell's Old Boys.
A minute's silence was held before kick-off in which the Sevilla players wore shirts with Maradona's number 10 on the back while the song 'My Dear Buenos Aires' played over the loudspeaker.