The hosts had trailed for much of the first period, but goals at the end of each half gave them their second consecutive league win.
Former Tottenham Hotspur forward Giovani dos Santos then sliced his effort wide from the middle of the penalty area as the hosts tried to get back on level terms.
They finally got their goal just before the break, and it came from the penalty spot. Dos Santos dispatched the spot kick after a foul on Jaume Costa.
Neither side were able to create anything significant in the second half, despite moments of quality from Javier Aquino for the hosts.
That was until the final five minutes when Cani produced the moment of the match to give Villarreal all three points, bursting past two defenders before smashing the ball into the top corner from distance.