The defeat was another blow to Barcelona and manager Xavi Hernandez after being on the verge of Champions League elimination following the midweek draw with Inter Milan.
Real Madrid are now on top of the standings with 25 points, three ahead of Barca.
Karim Benzema had opened the scoring on the night in the 12th minute by converting a rebound after Marc-Andre Ter Stegen saved Vinicius’ shot, It had been six consecutive games since the striker last scored a goal.
Fede Valverde drilled home the second from the edge of the box just before the break to place the Laliga champions in a much more comfortable lead.
Late on, Ferran Torres pulled one back for Barcelona after good work by Ansu Fati, but Rodrygo won and converted a late penalty to ensure Carlo Ancelotti’s side inflicted Barcelona’s first domestic defeat of the season.
Madrid ended the Catalans’ seven-game winning streak in the league and added to the still-raw pain of their struggles in Europe, where they are on the verge of Champions League elimination.
The result puts Los Blancos firmly back at the top of the table as they aim to defend their League title. Los Blancos also have their unbeaten run intact, whilst Barcelona have a lot of work to do.