Jordi Alba's early own goal was enough to consign Barca to defeat after coach Luis Enrique had left Lionel Messi and Neymar on the bench yesterday.
Earlier, Cristiano Ronaldo's first-half penalty looked to have Madrid on course to start the new year as they finished 2014, but Valencia roared back after the break with goals from Antonio Barragan and Nicolas Otamendi to move above Sevilla into fourth.
It is the first time since April 30, 2011 that both Madrid and Barcelona have lost on the same day and means Los Blancos retain their one point lead over the Catalans and Atletico Madrid having also played one game less than their title rivals.
"It is a lost opportunity. We have started the year badly, but we will keep going."
More From This Section
Real Madrid boss Carlo Ancelotti also lamented the chances missed by his side at crucial points in the game at Mestalla.
"I don't think we deserved to lose," said the Italian.
"We just didn't have the luck to score when we had the chances to make it 2-0, then to go ahead 2-1 and finally at the end when we had many chances to make it 2-2."
The World Player of the Year should have doubled his tally and his side's lead 12 minutes later when Bale's deflected cross fell perfectly into his path, but after rounding Diego Alves, Ronaldo could only turn the ball into the side-netting with the goal gaping.
Valencia also started the second-half in the ascendency as Andre Gomes sent a thunderous volley inches wide, but they were finally rewarded when Pepe turned a low drive from Barragan past the helpless Iker Casillas.