Jude Bellingham’s second-half double saw Los Blancos fight back from one goal down to take all three points.
After the game, Xavi claimed that his team deserved a result.
“We dominated 60 minutes, but this is football. We need five or six chances to score and they, with two or three, score two goals. It’s the difference.
“We lacked effectiveness. What we proposed went well, we were calm, patient… Maybe I’m exaggerating, but the feeling I have from the bench is that we deserved to win,” Xavi said.
The result means Barca are now four points behind Madrid after 11 games.