Cristiano Ronaldo opened the scoring for the visitors but the home side produced a stunning comeback to take all three points.Valencia brought Real Madrid's 22-match winning streak to a halt as it came from behind to win 2-1 at the Mestalla and blow the La Liga title race wide open.
First-place Madrid traveled to Mestalla to resume its season having won it last 22 competitive games, but was greeted by a fired-up, aggressive Valencia side not short on quality itself.
The home side were superb from the off, but the newly crowned Club World Cup champion still took an early lead courtesy of a controversial penalty from its talisman Cristiano Ronaldo — his 26th Liga goal of the campaign.
But the hosts were undeterred and forced a thoroughly deserved equalizer shortly after halftime through Antonio Barragan's first Liga strike since March 2007.
And, roared on by a boisterous home crowd, Nuno Espirito Santo's men edged in front in the 65th minute when Nicolas Otamendi rose highest to power a towering header beyond Iker Casillas from Dani Parejo's corner.
Carlo Ancelotti's side reacted well, but Valencia stood firm and claimed an invaluable three points that move it above Sevilla and into the top four.
Valencia started on the front foot, with its up-tempo, high-pressing game denying Real space and time on the ball. But despite the hosts' strong start, Real went in front after 14 minutes through — somewhat inevitably — Ronaldo.
Alvaro Negredo was ruled to have handled Gareth Bale's flicked header from a Toni Kroos free kick inside the area, and the Portuguese duly stepped up to send Diego Alves the wrong way from 12 yards.
If Madrid was slightly fortunate to be given that penalty, it had every right to feel aggrieved that referee Jesus Gil did not point to the spot again 11 minutes later.
Bale was again involved, and Lucas Orban clearly handled his cross toward Ronaldo. But the Ballon d'Or favorite should have scored anyway, as he somehow fired into the side-netting after latching onto the loose ball and rounding Alves.
Ronaldo was almost made to pay for his uncharacteristic profligacy on the stroke of halftime, when Andre Gomes' left-footed shot from 20 yards was deflected onto the post with Casillas stranded, before the Real skipper reacted quickest to deny Paco Alcacer on the rebound.
Gomes again came agonizingly close immediately after the restart, as he lashed a volley narrowly wide with Casillas beaten.
But Valencia finally got it just reward courtesy of the most unlikely of sources in the 52nd minute, as Barragan's speculative shot took a wicked deflection off Pepe and gave Casillas no chance.
The home crowd was sent into raptures once again with 25 minutes remaining, when Otamendi powered a bullet header past Casillas from Parejo's outswinging corner.
Madrid was on the ropes and Valencia should have gone further ahead soon after, only for Barragan to side-foot wide following a free-flowing passing move.
Ancelotti's men quickly regained their composure and laid siege to their opponents' goal for the remainder of the game.
Sergio Ramos, Ronaldo and Isco all came close to finding a late equalizer, but Valencia was not to be denied a famous victory as the Champions League winners were condemned to a first defeat since September.