Angel Di Maria gifted Madrid the lead early in the first half, before Marc Bartra leveled the scoring after the interval, but Gareth Bale eventually helped the Santiago Bernabeu side to victory with a stunning late run and finish.
Dani Alves admits the timing of the Welshman's winner was a bitter blow to Barca in what has been "a very strange year" for the Catalans.
"I apologize to the people who came out to cheer us on. It's a shame that we lost," the Brazil international told the official Barca website. "When we were at our best they scored the second goal, and we were unable to fight back.
"This team has a lot of worth and we work very hard. It's been a very strange year for us."
Barcelona has now lost three games in a row after previous defeats against Atletico Madrid in the Champions League and Granada in La Liga.
The club will be desperate to return to winning ways on Sunday when it hosts Athletic Bilbao as it aims to keep its title ambitions alive.