Luis Suarez started for Barcelona after a four-month ban for biting and set up Neymar to arrow in the opener.
Barcelona’s Lionel Messi spurned a glorious chance before Cristiano Ronaldo equalised with a penalty.
A powerful header from Pepe put Real ahead before they added to their lead when Karim Benzema finished a brilliant counter-attack with an angled shot.
The Real fans roared their approval at the end as as the home side came out on top in a match-up between two of the world’s most star-studded line-ups.
Real’s celebrations following the 229th meeting between the two were also heightened with the victory helping them close the gap to one point on La Liga leaders Barcelona.
The visitors may have taken the lead but were ultimately disappointing as they failed to match the greater cutting edge in attack and solidity in defence of the home side as they suffered their first league defeat of the season.
A game between these two Spanish giants is usually one to savour and it was even more so this time considering the array of talent on show.
Real had Ronaldo, James Rodriguez and Benzema up front, while Barcelona had Messi, Neymar and Suarez.
Suarez starting added to the spectacle as he played for the first time since his ban for biting Italy defender Giorgio Chiellini at the World Cup came to an end.
The Uruguayan made an immediate impact when his crossfield pass found Neymar, and the Brazilian cut in from the left and curled in a low shot for the opener.