Alaves, who had won just two LaLiga matches this season coming into the game but look a side on the up, took an early lead through a penalty from Lucas Perez.
Los Blancos had recovered from the loss of Eden Hazard to another injury problem after only 30 minutes to come back into the game – only for a costly error from Courtois to gift the visitors another goal.
Just a couple of minutes into the second half, the Belgium international knocked a backpass straight to Joselu, who slotted the former Chelsea goalkeeper's stray ball into an empty net.
Both teams paid their respects to Diego Maradona before kick-off, with Alaves, hoping to build on a four-game unbeaten run that included draws against Barcelona and Valencia, soon taking the lead from the penalty spot.
Victor Laguardia headed the ball down from a corner, with the referee signalling for handball against Real defender Nacho.
Perez struck the penalty past Courtois to put the visitors in front after just four minutes.
Los Blancos, who won 2-0 at Inter Milan in the Champions League on Wednesday night, slowly regrouped, but Alaves remained a threat on the counter-attack.
Belgium midfielder Hazard was forced off with what looked like another injury problem after half-an-hour, replaced by Rodrygo.
The reigning Spanish champions fell further behind just five minutes after the restart following a blunder from Courtois.
The 28-year-old collected a bouncing back-pass from Marcelo, took a touch – but then contrived to knock the ball straight out to Joselu, who sent his shot back into an unguarded net.
Courtois then produced a smart stop to deny Alaves a third as Perez ran clean through on goal.
Rodrygo dragged his shot wide, before Mariano's header was cleared off the line.
With five minutes left, Casemiro knocked the ball in from close range after a corner, but there was to be no late drama.