The victory is a big one for Zinedine Zidane who was under pressure after two shock defeats to newly promoted Cadiz in La Lifa and an under strength Shakhtar Donestsk in the Champions League in midweek.
- Insider Notebook: No Sanchez-style pay bump for Pogba
It was a frantic opening 10 minutes with Valverde scoring after just five minutes and Fati equalising for Barcelona four minutes later.
The goal kicked some life into Barcelona and Jordi Alba picked out 17-year-old Fati on nine minutes with a perfect pass that allowed the teenager to make a clever run before putting the ball in the right-hand corner.
The intensity of the opening minutes continued throughout the half with both goalkeepers kept busy but neither side able to find a lead.
There were calls from Barcelona for a penalty on 28 minutes when Lionel Messi went down under a challenge from Casemiro. However, a VAR check confirmed that the Real Madrid midfielder had secured the ball before catching Messi and no penalty was awarded.
There was nearly a second for Fati on 52 minutes, who nutmegged Ramos before getting off a shot that flashed past the far post and out for a goal kick.
However, Ramos got his revenge on 63 minutes when he won and scored a penalty to give Real Madrid the lead.
Neto dived the right way for the penalty but couldn't get a hand to the ball.
Modric made sure of a Real Madrid win on 90 minutes getting around Neto before firing into an empty goal.
"It was the plan for the game to have control of the game," Barcelona head coach Ronald Koeman said after the match. "We changed Leo's position, put Ansu as a reference point. Tried to look for space behind Madrid's defence and have players on the wide with good ball control, going between lines and one reference up front. Can be happy in that sense, we played well.
"When you're losing, we have to try and improve and create chances to score with the players on the pitch.
"We opted to freshen things up wide with Ousmane [Dembele] and [Francisco] Trincao, to get in one-on-one positions with more speed. Antoine [Griezmann] too up front with Leo. Then try from the 35th minute to take risks."