Match ends, Real Madrid 2, Barcelona 0.
Real Madrid beat Barcelona in a captivating El Clasico to move above their rivals at the top of La Liga.
Vinicius Junior drove in via a deflection in a second half packed with chances after Isco saw a shot saved and an effort cleared off the goalline.
Karim Benzema volleyed over for Real and substitute Martin Braithwaite went close for Barca moments before Vinicius sparked celebrations at the Bernabeu.
Substitute Mariano struck in added time as Real moved a point clear of Barca.
Mariano had not played a single minute in La Liga for Zinedine Zidane's side this season until being brought off the bench in injury time to seal a memorable win.
Los Blancos finished third last season - 19 points behind champions Barca - but the tight nature of the title race this time around placed added significance on the fixture in the Spanish capital.
Zidane had said his side were in a "delicate moment" as a result of picking up one point from their last two league matches and having suffered a home defeat to Manchester City in the Champions League in midweek.
And Real's task looked ominous given they had not beaten Barca in the league in their last seven attempts.
Quique Setien's side also arrived having won four league games in a row at the Bernabeu but they will rue missed opportunities in the first half.
Antoine Griezmann fired over from a Jordi Alba cut-back, Arthur was denied by Thibaut Courtois after breaking through on goal and the Madrid keeper parried a Messi effort when the Barca talisman broke the offside trap.
Going into the break, Courtois had saved 30 of the last 36 shots he had faced in La Liga and his interventions were built upon as Zidane's side carried more threat in the second period.
Isco curled an effort at the top corner to force a fine save from Marc-Andre ter Stegen before heading low past the keeper, only for Pique to intervene.
Karim Benzema could not end a five-game goal drought when he volleyed over when unmarked before former Middlesbrough forward Martin Braithwaite had a chance to win it, only for his shot to be saved.
Vinicius then pounced, firing in from a narrow angle, the 19-year-old Brazilian becoming the youngest scorer in a league game between the sides this century as he surpassed Lionel Messi's record set in 2007.
His side never looked back and Mariano put the finishing touches on a win which gives them real hope of landing a first league title since 2016-17.
'Worst I have seen Madrid play at the Bernabeu' - reaction
Real Madrid manager Zinedine Zidane: "We deserve our victory for everything we did, in attack and defence. It has been a complicated week for us and we had the chance to turn things around, and we did that.
"But this win also doesn't change anything. We have a long way to go and we have to continue. We've got three important points but we'll have more difficult games and we will be criticised again."
Barcelona manager Quique Setien: "We were clear about what we had to do. We had to wait for our moment and be patient and try to keep the ball.
"In the second half I can't understand why we started to lose the ball easily. We were able to breathe life back into Real Madrid. It was a shame we weren't to take the form of the first half into the second."
Barcelona defender Gerard Pique: "We controlled the game in the first half, which was the worst I have seen Madrid play in all the years I have played at the Bernabeu.
"We had a chance to make a real statement and if we had taken our chances they would have had a mountain to climb.
"They come out of this game feeling very strong while we feel down but we are not out. I think there is still time for us to win the league."
- 2CarvajalBooked at 19mins
- 15ValverdeSubstituted forVázquezat 86'minutes
- 22IscoSubstituted forModricat 79'minutes
- 25Vinícius JúniorBooked at 10mins
- 9BenzemaSubstituted forMarianoat 90+1'minutes
- 1ter Stegen
- 2Nélson Semedo
- 18AlbaBooked at 19mins
- 22VidalSubstituted forBraithwaiteat 69'minutes
- 8ArthurSubstituted forRakiticat 80'minutes
- 21de Jong
- 10MessiBooked at 85mins
- 17GriezmannSubstituted forFatiat 81'minutes
- 13Murara Neto
- Antonio Miguel Mateu Lahoz
- Shots on Target
Second Half ends, Real Madrid 2, Barcelona 0.
Goal! Real Madrid 2, Barcelona 0. Mariano (Real Madrid) right footed shot from a difficult angle on the right to the centre of the goal. Assisted by Daniel Carvajal.
Substitution, Real Madrid. Mariano replaces Karim Benzema.
Ivan Rakitic (Barcelona) wins a free kick in the attacking half.
Foul by Vinícius Júnior (Real Madrid).
Attempt blocked. Sergio Ramos (Real Madrid) right footed shot from outside the box is blocked.
Foul by Sergio Busquets (Barcelona).
Lucas Vázquez (Real Madrid) wins a free kick in the attacking half.
Foul by Gerard Piqué (Barcelona).
Karim Benzema (Real Madrid) wins a free kick in the attacking half.
Offside, Real Madrid. Toni Kroos tries a through ball, but Vinícius Júnior is caught offside.
Substitution, Real Madrid. Lucas Vázquez replaces Federico Valverde.
Lionel Messi (Barcelona) is shown the yellow card for a bad foul.
Foul by Lionel Messi (Barcelona).
Casemiro (Real Madrid) wins a free kick in the defensive half.
Attempt missed. Gerard Piqué (Barcelona) header from the centre of the box is high and wide to the left. Assisted by Lionel Messi with a cross following a set piece situation.
Ansu Fati (Barcelona) wins a free kick on the left wing.
Foul by Luka Modric (Real Madrid).
Gerard Piqué (Barcelona) wins a free kick in the defensive half.