Karim Benzema grabbed a goal back for Madrid but they were unable to score an equaliser and suffered their first LaLiga defeat of the season.
The result completes a poor week for Carlo Ancelotti’s men after they also slipped to a surprise loss to Sheriff in the Champions League on Tuesday.
Madrid dominated possession from the start but went behind after 23 minutes when De Tomas scored from close range.
Benzema got Madrid back in the game 11 minutes later with a clinical finish into the bottom corner.
With six minutes remaining, Madrid thought they grabbed an equaliser through Eden Hazard but his goal was ruled out for offside.