Published: 2021-04-11 03:12:49 BdST
Karim Benzema put the champions in charge at a soggy Alfredo di Stefano stadium with a delightful backheel in the 14th minute while a deflected Toni Kroos free kick doubled their lead in the 28th.
Barca hit back on the hour mark through Oscar Mingueza and the defender almost found the equaliser later on, while the Catalans had a huge penalty appeal waved away when Martin Braithwaite fell following a challenge by Ferland Mendy.
Real midfielder Casemiro was sent off in stoppage time for picking up two yellow cards in the space of a minute while Barca substitute Ilaix Moriba hit the crossbar in the fourth minute of added time.
The hosts survived the nail-biting finish to complete the double over Barca in a league season for the first time since 2008 and round off a sensational week after beating Liverpool 3-1 in a Champions League quarter-final first leg on Tuesday.
Zinedine Zidane's side joined Atletico Madrid on 66 points and moved top of the table, although Atletico can reclaim first place when they visit Real Betis on Sunday.
Barca, who lost for the first time in the league since early December, dropped to third on 65.
Barca looked to dominate possession but were powerless to control Real's counterattacks and went behind when Federico Valverde hurdled a Jordi Alba tackle to shuttle down the pitch, feeding Lucas Vazquez whose low cross was turned in by Benzema's sublime backheel.
Real caught Barca out on the break again when Vinicius Jr. raced on to a Luka Modric pass and was felled by Ronald Araujo. The free kick was in perfect range for Kroos, whose shot bounced off the back of Sergino Dest to wrong-foot Barca keeper Marc-Andre ter Stegen.
Real were inches away from scoring a third when Valverde again tore down Barca's left-hand side and smacked the far post, Vazquez pouncing on the rebound but shooting straight at Ter Stegen.
Barca barely caused Real any trouble until the end of the first half, when Lionel Messi hit the far post straight from a corner. The Argentine had a better chance moments later from inside the area but could not beat Madrid's Thibaut Courtois.
Koeman took decisive action at halftime, throwing on Antoine Griezmann for Dest and the French substitute helped pull Barca back into contention, playing a dummy which led to Mingueza scoring.
The torrential rain caused Messi to change his soaked shirt late in the game and the slippery conditions helped set up the frantic finish, but Real weathered the storm.