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.
Barcelona coach Ronald Koeman was left fuming afterward by the decison to reward his side a penalty.
"First of all I want to say in the first half we weren't good, attacking or defending," Koeman said. "Second half we improved and I only ask that the referees get decisions right.
"It's a penalty and four minutes of extra time when the referee had three minutes with his shoulder issue. The penalty is clear."
Real midfielder Ilaix Moriba hit the crossbar in the fourth minute of added time.
"Winning a Clasico is always special, with how the table is, it's so tight, it was really important. Today you could say it was a final but there are a lot of games left, they're a direct rival, but we still have to fight for a lot," Real Madrid's Nacho said after the match.
The hosts survived the nail-biting finish to complete a sensational week after beating Liverpool 3-1 in a Champions League quarterfinal first leg on Tuesday.
Barca, who lost for the first time in the league since early December, dropped to third on 65.
"We kept on trying until the end to equalise and we'll keep on fighting for the title," said Barca defender Sergi Roberto.
"We had our fate in our own hands before now but not anymore, so we have to win the games we have left and hope the others drop points."
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.