Real swallowed chastening defeats by Levante in La Liga and Manchester City in their Champions League last 16, first-leg tie in the past week.
But in the second half they overwhelmed Barcelona, threatening on numerous occasions before breaking the deadlock.
Vinicius the star
Madrid's main threat was the electric but raw Vinicius, who routinely got down the left but rarely knew what to do next.
There was a touch of fortune to the deflected opening goal, but Real's victory was thoroughly deserved.
Real looked far more determined in the second half ain the match played at home.
Isco forced Ter Stegen into an outstanding flying save and then saw a downward header scrambled off the line by Pique.
Barcelona had bossed the first period and twice could have taken the lead but were powerless to stop Real after the interval and their impotence was summed up when Lionel Messi raced towards goal but was easily tracked down by Marcelo.
Marcelo's tackle got as loud a cheer as the goals from Madrid's fans who had not been able to toast a league win over Barcelona at the Santiago Bernabeu since 2014.