Middlesbrough tasted defeat in Europe for the first time, but barring a mathematical miracle will find themselves in the hat next month for the last 32 of the UEFA Cup.
Goals from Antonio Guayre and Javi Venta either side of the interval ensured manager Steve McClaren's tactical gamble backfired at the Estadio El Madrigal.
But Middlesbrough remain in the driving seat for a top-three finish in Group E and with it a place in the knockout stages, with only Egaleo capable of spoiling the party.
McClaren gambled by naming strikers Jimmy Floyd Hasselbaink and Mark Viduka, as well as influential midfielder Ray Parlour, on the substitutes' bench.
McClaren opted for a 4-5-1 formation, with Job ploughing the lone furrow up front, while Szilard Nemeth and Doriva came into midfield.
For 37 minutes, Boro were composed and organised and there appeared little to fear from a Villarreal side that last season reached the semi-finals of this competition, but are currently struggling in 13th in the Primera Liga.
It took the home side 25 minutes to produce their first chance, and that was a shot from the corner of the penalty area from Santiago Cazorla which was easy for Mark Schwarzer.
On 36 minutes Schwarzer was comprehensively beaten as a superb through ball from Riquelme found Guayre who, after outpacing Chris Riggott, fired home a flashing, first-time right-foot drive from 12 yards.
Villarreal clinched victory when Javi Venta played a delightful one-two on the edge of the area with Riquelme before rifling a drive into the roof of the net.
VILLARREAL: Reina, Javi Venta, Rodriguez, Quique Alvarez, Arruabarrena, Josico, Arzo, Hector Font, Riquelme, Santi Cazorla, Guayre (Xisco Nadal 87), Pena (Armando Sa 87). Subs not used: Lopez Vallejo, Pena, Garcia, Jonathan. Goals: Guayre 36, Javi Venta 74.
MIDDLESBROUGH: Schwarzer, McMahon (Reiziger 72), Riggott, Southgate, Queudrue, Nemeth, Doriva (Hasselbaink 45), Zenden, Boateng, Downing, Job (Viduka 45), Reiziger. Subs not used: Nash, Parlour, Cooper, Morrison. Booked: Southgate, Zenden.
Referee: Jan Wegereef (Holland).