The Catalans took a 20th-minute lead thanks to Jeremy Mathieu???s header, only for Cristiano Ronaldo to equalise just past the half-hour mark with his 42nd goal of the season in all competitions.
However, Luis Enrique???s side claimed what could turn out to be a vital victory thanks to Luis Suarez???s 57th-minute strike, the Uruguayan???s first-ever El Clasico goal.
It was Barcelona, as befits the home side, who made the faster start as they went in search of the win that would give them clear daylight in the title race.
However, despite bossing the early exchanges – as one would expect from a team with 17 victories to their name in the previous 18 matches since surprisingly losing at Real Sociedad back in December – it was Real who created the first real opening of the evening.
And it came when Ronaldo escaped the attentions of the Barcelona defence at the back post after being picked out by a delicious ball from Karim Benzema, only for the Portuguese forward???s effort to beat Claudio Bravo, but not the crossbar.
Barcelona then responded to that near miss by taking the lead, and through the most unlikely of scorers in the shape of centre-back Mathieu, who got the better of Sergio Ramos to power Lionel Messi???s inch-perfect free kick from the left past Iker Casillas.
But the visitors took just 11 minutes to draw level, although only after Barca forward Neymar had somehow missed an open goal from only six yards out, a glaring miss that was even more important when Madrid equalised seconds later.
It was a beautifully worked goal too from Real involving Gareth Bale and Luka Modric, with the Croatian playing Karim Benzema through on goal, before his cute back-heel found Ronaldo, with the World Player of the Year making no mistake with his ninth goal in only 11 matches at the Nou Camp.
And Madrid would have gone in at the break 2-1 ahead had Bale, who also had a goal correctly disallowed for offside, not somehow missed from close range, or had Claudio Bravo not reacted smartly to tip over a rasping drive from Ronaldo.
After the interval it was Barcelona who moved up a gear, although not before Bravo was first called upon to keep out Benzema???s close-range effort after a fantastic move between Ronaldo and Modric four minutes into the second period.
Then came the decisive moment of the match as Dani Alves found Suarez with a high ball over the Real back four, although the forward still had much work to do to bring the ball out of the sky, before coolly finishing low past Casillas for his 14th goal of the campaign.
And thereafter it was all Barca as the Catalans missed a whole host of chances with Messi, twice, Neymar and Jordi Alba all wasting presentable openings to double their side???s advantage.
But Barcelona were not made to pay for their profligacy in front of goal though, with the closest Madrid coming to grabbing an undeserved equaliser coming when Benzema???s deflected shot from the edge of the area forced Bravo into a smart reaction save 12 minutes from time.