Portugal international Goncalo Guedes fired Valencia into the lead in the 35th minute with a thumping shot from inside the area which was too powerful for Madrid goalkeeper Keylor Navas.
Madrid had played well until conceding, but lost momentum after the goal and Valencia continued to threaten into the second half, finally doubling their lead with a header by defender Ezequiel Garay from a corner in the 83rd.
Valencia, who have reached the Copa del Rey final and the quarter-finals of the Europa League, have Champions League qualification in their sights after climbing up to fifth in the table on 46 points, one behind fourth-placed Getafe.
Madrid are stuck in third on 57 points, 13 behind La Liga leaders Barcelona and five behind city rivals Atletico Madrid.