Real, Barca both lose
Valencia came from behind to snap Real Madrid's winning streak at 22 games, however Barcelona failed to take advantage as they also lost 1-0 at David Moyes's Real Sociedad on Sunday.
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.
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.
Madrid now lead Barcelona and Atletico Madrid by just a point, but the European champions have also played one game less than their title rivals.
Victory for Valencia, meanwhile, was a huge boost to start the year they hope will culminate with a return to the Champions League.
Despite a bright start Valencia had to come from behind at Mestalla when Alvaro Negredo handled Gareth Bale's flick on from Toni Kroos's free-kick and Ronaldo duly stepped up to fire home his 33rd goal of the season from the penalty spot.
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 ascendancy 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.
Bale had a great chance to restore Madrid's lead when he galloped in behind the Valencia defence seven minutes later, however the Welshman was denied by a fine saving challenge from Otamendi.
And just moments later, the Argentine centre-back was the star at the other end of the pitch as he towered above Ramos to power a header high past Casillas.
Madrid rallied in the final 15 minutes, but couldn't find an equaliser as Ramos sent a header inches wide before Alves denied Isco with a brilliant save from point-blank range and Otamendi cleared the danger before a Madrid player could pounce on the rebound.