- Karim Benzema (12')
- Federico Valverde (35')
- Rodrygo (90'+1' Pen)
- Ferran Torres (83')
However, Carlo Ancelotti's side sealed the victory in stoppage time with a Rodrygo penalty.
The result compounded a miserable week for Barcelona manager Xavi Hernandez, who saw his side lose ground in the league title race after slipping to a disappointing Champions League draw in midweek.
Madrid remain unbeaten in LaLiga with 25 points, while Barca is in second place (22).
The hosts took the lead after 12 minutes through a swift counterattack that saw Benzema tap home after Marc-Andre ter Stegen blocked Vinicius Junior's effort.
The France international snapped a streak of five games without a goal, which was his longest scoring drought at the club level since 2020.
Madrid doubled their lead 10 minutes before the break when Valverde found himself in space outside of the box and steered a fine finish past Ter Stegen.
Benzema thought he grabbed a second goal early in the second half, but it was ruled out for offside.
Madrid stepped up a gear and were awarded a penalty in the 90th minute when Sergio Busquets brought down Rodrygo.
The Brazilian scored the spot kick as Madrid avenged their 4-0 Clasico home defeat last season.
- José María Sánchez Martínez