Madrid largely dominated proceedings on home soil, but Villarreal snatched all three points and a first league victory at Madrid in 18 attempts with three minutes left thanks to Fornals' exquisite chip after Enes Unal's shot was saved.
It compounded a day of utter frustration for an out-of-form Madrid, which felt it twice should have had a penalty in the first half.
Villarreal defender Alvaro Gonzalez was lucky to not face punishment for handball from a Gareth Bale header, while Cristiano Ronaldo was adamant he was fouled by Mario Gaspar on the stroke of half-time.
Referee Alberto Undiano Mallenco was unmoved on both occasions, while Madrid was further frustrated by a poor one-on-one miss by Ronaldo and some good work by Villarreal goalkeeper Sergio Asenjo.
Madrid has now won just once in five LaLiga matches and will be 19 points adrift of Barcelona if its rival beats Real Sociedad on Monday, while Villarreal is just one point adrift of Los Blancos in its bid to muscle in on the top four.