Cristiano Ronaldo gave Madrid the lead with an early penalty, but Valencia turned the match on its head with goals from Antonio Barragan and Nicolas Otamendi early in the second half.
Madrid were hunting a 23rd straight win as they closed in on Coritiba’s world record of 24 in a row, but Valencia’s impressive home record – only Barcelona have won at the Mestalla this season – proved their undoing.
David Moyes’ Real Sociedad held on to record a narrow 1-0 victory over Barca as they returned to winning ways at a damp Anoeta.
An early own goal from Jordi Alba was all the hosts needed as they held off a second-half onslaught from substitute Lionel Messi, with Luis Suarez also denied as Sociedad moved up to 13th in the Primera Division table.
Goalkeeper Geronimo Rulli and the Sociedad defence worked hard to keep the Catalans at bay during Moyes’ eighth game in charge as Sociedad claimed their third home victory in succession over Barca, who remain one point behind Madrid.
Rayo Vallecano recovered from conceding after only two minutes to end a three-match losing run in the league with a 2-1 victory at Getafe.
In their first game back after the winter break, Rayo got off to a terrible start as Alvaro Vazquez fired home a 25-yard free-kick.
Jozabed levelled before half-time, though, and Raul Baena converted from close range shortly after the hour mark to complete the turnaround.
Eibar enjoyed a stellar 2014 and carried it over to 2015 by taking all three points from their opening match of the year, a 2-1 win over Espanyol at the Power8 Stadium to move up to eighth.
Manu del Moral opened the scoring for the visitors in the 34th minute and moments later Eneko Boveda widened the gap with a headed goal from a corner.
Felipe Caicedo pulled one back late on but the Catalans were unable to avert a second home defeat of the season, which sees them fall three points behind the Basques.