In a match watched by hundreds of millions around the world, Barca landed an early blow in the title race thanks to Neymar's clinical 19th-minute finish and a sublime chip from substitute Alexis Sanchez 11 minutes from time.
Jese came off the bench to pull a goal back in the first minute of added time, but it was little more than a consolation for Real, who were outplayed for long periods and slip six points behind the champions with 10 matches played.
After a cagey opening with few chances, Neymar opened the scoring when he collected the ball from Andres Iniesta on the left of the penalty area. Cutting inside on to his right foot, he fired off a low shot which took a slight deflection off Real full-back Dani Carvajal before zipping past goalkeeper Diego Lopez into the far corner of the net.
Real battled hard in the second half and Karim Benzema, who replaced ineffective world- record signing Bale on the hour, smashed a shot against the bar before Alexis scored with an exquisite chip over Lopez from just outside the area.
"These are the kind of games when everyone really suffers but I am just happy for the team and for the three points," said Alexis.
"I don't think this win will be decisive," added the Chilean. "There is a long way to go and the championship is not over by any means."
Jese's goal came too late for Real to stage a comeback and coach Carlos Ancelotti and his team must now regroup before Wednesday's game at home to Sevilla.
"There are some things you cannot fight against," said Ramos. "There was a clear penalty for handball in the first half and then the incident with Cristiano Ronaldo in the second. But I think that all Madrid fans should be proud of the team as we battled until the last minute. It's been a long time since we saw Barca under pressure at the end and running the clock down like that," added the Spain international.
Unbeaten Barca's victory, their ninth in the league this season, puts them on 28 points ahead of third-placed Real at the top of the standings.
Second-placed Atletico Madrid are four points behind Barca before their game at home to Real Betis today.