Jonas headed Valencia into the lead from a corner kick inside 60 seconds.
Two goals from Riki then turned the game on its head to put the hosts ahead at half time.
Buoyed by their numerical advantage, Valencia dominated the remainder of the match and deservedly pulled level on 63 minutes when Nelson Valdez tapped home from close range following a brilliant low cross from Juan Bernat.
Deportivo's poor defensive marking was exposed again in stoppage time as Ricardo Costa headed home a dramatic winner.
Clearly frustrated by his side's plight, Paulo Assuncao committed an awful challenge on Valdez moments later and was rightly shown a straight red card.