Karim Benzema broke the deadlock with a sublime near-post flick – his ninth goal in his past seven La Liga games.
Real doubled their lead before half-time through Toni Kroos’ deflected free-kick.
Oscar Mingueza pulled one back for Barca before Madrid’s Casemiro was shown a late red card.
Barca midfielder Ilaix Moriba’s well-struck shot came back off the crossbar in stoppage time as the hosts held on.
The result takes Real above city rivals Atletico Madrid because of their superior head-to-head record.
Atletico, who led La Liga by 10 points as recently as 31 January, can reclaim the top spot with victory at Real Betis on Sunday.
Real survive the tense finale
Manager Zinedine Zidane’s “every game is a final” mantra has served Real well in recent weeks – they had dropped only four points in their previous nine La Liga outings going into Saturday’s crucial game.
Benzema’s goals have been key in helping them cut the gap to rivals Atletico at the top of the table, and the Frenchman produced another exquisite finish to give Zidane’s side an early lead.
The 33-year-old was first to Lucas Vazquez’s low cross towards the near post, squeezing a backheeled flick past Marc-Andre ter Stegen for his 25th goal in 35 appearances this season.
Barcelona, who had revived their own title aspirations with 16 wins and three draws from their previous 19 La Liga fixtures, dominated possession but fell further behind when Kroos’ free-kick took a deflection off Sergio Dest on its way past Ter Stegen.
Federico Valverde could have made it 3-0 before half-time, but his fierce drive across goal came back off the inside of the far post.
Barcelona coach Ronald Koeman switched from a 3-5-2 to a 4-3-3 formation in the second half and the move paid off 15 minutes after the restart, Mingueza turning Jordi Alba’s cross past Thibaut Courtois to set up a tense finish.
Vinicius Junior was denied by the post as Real threatened to restore their two-goal advantage before Lionel Messi (who had rattled the woodwork in the first half with an inswinging corner ), struck the wall from a free-kick on the edge of the box.
Barcelona had a penalty appeal turned down when Martin Braithwaite went to the ground under Ferland Mendy’s challenge, before a late tackle on Mingueza earned Casemiro a second yellow card.
The visitors almost snatched a draw in second-half stoppage time when Moriba thumped a loose ball against Courtois’ crossbar, but Real held on to record three consecutive El Clasico wins for the first time since 1978.
Barcelona manager Ronald Koeman said: “I think everyone who saw the game will see that we can be very unhappy with the result.
“I think we weren’t good at all in the first 45 minutes. We weren’t good in attack or in defense, but in the second half, we improved.
“We need to be better when making key decisions. They’re decisions that can cost us the game and in the end, they did.
“I think we should have got a clear penalty towards the end, and I don’t know why it wasn’t reviewed by VAR.”
Real Madrid manager Zinedine Zidane said: I feel very happy. We started the game very well. It was a very complicated match overall, but it was a deserved victory.
I think we could have scored a third goal, but it’s an important win. We did our job today.
Follow Us In Android Application Install