Federico Valverde celebrates with  Karim Benzema after scoring his team's second goal.
CNN  — 

Real Madrid and Barcelona both took to the field unbeaten in La Liga this season, with Barça leading its rival on points difference at the top of the league.

But after the centenary edition of El Clásico at the Bernabeu stadium, it was Real Madrid who stamped its authority on the league with a 3-1 victory on Sunday, despite a late comeback from Barcelona.

Madrid seemed to be cruising to victory after goals from Karim Benzema and Federico Valverde had given it a 2-0 lead at halftime, while midway through the second half, Benzema celebrated as if he had added a third only for it to be chalked off for offside.

But as the game appeared to be petering out towards a regulation Madrid win, Barcelona struck through Ferran Torres to make it 2-1 and set up a grandstand finale.

Although Barcelona continued to press for an equalizer, it was Madrid who confirmed its ultimately comfortable victory late on with a Rodrygo penalty.

Rodrygo's penalty in the 90th minute confirmed Madrid's victory.

Each side had experienced very different run-ins to the weekend.

While Madrid had progressed into the Champions League knockout stages on Wednesday, Barcelona’s hopes of a last-16 berth now hang by a thread after a dramatic draw against Inter Milan.

The European champions Real showed its ruthless streak in the first half, clinically taking a 2-0 lead into the break.

First, 12 minutes in, Karim Benzema fired a deflection into the goal after Vinícius Júnior outstripped Sergi Roberto down the wing but could not get his initial effort past goalkeeper Marc-Andre ter Stegen.

Then a glorious team effort doubled Madrid’s lead 23 minutes later, as Valverde finished off slick passing from Vinícius Júnior, Aurélien Tchouaméni and Ferland Mendy.

Valverde's goal put Real Madrid firmly in control.

Barcelona had only glimmers, half chances that stalled at the last moment – like a ball slid to Robert Lewandowski that his foot could only scoop over, rather than into, the goal – as it struggled to unlock Real Madrid’s defense.

And after halftime, the pattern continued with Real controlling possession with ease until on the stroke of 83 minutes when substitute Anssumane Fati’s cross found Torres to pull his side back into contention.

Fati injected some urgency into Barcelona’s attack but just as the game began to open up, the referee awarded Madrid a penalty for Eric García’s trip on Rodrygo.

Rodrygo stepped up to the spot and made no mistake with the finish to confirm his side’s victory and its place at the top of the table.