Madrid broke the deadlock in the 41st minute when Mbappé found the net after a cross from Yan Diomande deflected off Barcelona defender Gerard Martín and into the goal.
Barcelona responded strongly after the break and restored parity in the 61st minute through Raphinha, who finished from close range after receiving a pass from Pedri.
The hosts gained momentum following the equaliser and pushed for a second goal, but Madrid goalkeeper Andriy Lunin produced important saves to keep his side in the contest.
Just when Barcelona appeared to be gaining control, Real Madrid struck again in the 87th minute. Eduardo Camavinga set up Mbappé following a counterattack initiated by Jude Bellingham, allowing the Frenchman to score his second goal of the night and seal a crucial victory for the visitors.
The result marked Barcelona’s first domestic defeat of the season and gave Real Madrid a significant boost in the La Liga title race.
Despite the loss, Barcelona will be eager to bounce back in their upcoming fixtures, while Madrid will look to build on the victory as the battle for domestic supremacy continues.