Martin Braithwaite (30th) scored the opening goal for Barca, Antoine Griezmann (42nd), ex-Munich Philippe Coutinho (52nd) and superstar Lionel Messi (73rd) increased to 4: 0 with a dream goal. Barcelona moved up to within three points of Real.
For the Catalans, captain Messi was back in the starting line-up after he was last spared in the Champions League game by coach Ronald Koeman. Goalkeeper Marc-Andre ter Stegen was the usual secure support of his team.
Atletico Madrid, who played in the Champions League on Tuesday at defending champions Bayern Munich, won 1-0 (0-0) at Valencia CF on Saturday and stayed in touch with the top.
Real has been waiting for a win for three league games. Lucas Perez (5th) gave the guests the lead with a converted hand penalty, aided by a bad pass by Belgian goalkeeper Thibaut Courtois, Joselu (49th) extended the Alaves lead shortly after the restart. Casemiros (86th) connection goal was without consequences.