Needing just a draw to go through to the knockout stages, Villarreal won at Atalanta, with the late flurry for the hosts in vain.
Former Bournemouth striker Arnaut Danjuma scored early in each half for the Yellow Submarine, with Etienne Capoue also hitting the target to put them three ahead and leaving Atalanta need four goals to qualify.
Incredibly they were not too far from doing so.
Atalanta and Inter in entertaining goalless draw
- Elmas double sends Napoli through as Leicester drop into Conference League
- Opinion: Man Utd have the chance to break player power under Rangnick
- Parker: Forget unbeaten start, Rangnick must shift dead wood at Man Utd
Before scoring their first Ruslan Malinovsky saw a free kick come back off the angle of post and crossbar and then, after Duvan Zapata dinked a second, another substitute Luis Muriel curled an effort against the inside of the post with five minutes remaining.
The win sees the Spanish outfit finish second in the group behind Manchester United with 10 points, Atalanta finish third with 6 and go into the Europa League.
TALKING POINT - EMERY'S EMBOSSES EXCELLENT EURO RECORD
Villarreal's la Liga form has been patchy at best this season. They are currently placed 13th in the table with only three wins to their name.
But the four-time Europa League winner (plus a runner-up with Arsenal) produced another fantastic result for his side in continental competition.
Needing just a point to qualify, many coaches would have played for a draw, but he kept a full compliment of skillful attacking players and this paid dividends in the first half.
They are certain to be a heavy underdog whoever they play in the knockout stages but, whatever happens, winning a crunch game in Italy is another feather in their coach's cap and will give his players confidence they can do similar again.
MAN OF THE MATCH - ARNAUT DANJUMA (VILLAREAL)
Danjuma was voted the Bournemouth player of the year at the end of his second season, but he seems to have taken a step up since joining the Yellow Submarine in the summer. His brace today gives him four goals in the Group Stages, to go with five goals in nine starts in la Liga.
His mastery of the ball, and apology for the heresy, is a little Thierry Henry-like and makes it so hard for any defender to deal with him one-on-one. It would have been frowned upon had he missed the chances for his two goals, but many lesser players would have lost their cool running half the distance of the field for the first and his slick turn made the second a lot easier than it might have been.
Atalanta: Musso 6; Toloi 6, Demiral 6, Palomino 6; Hateboer 6, De Roon 6, Freuler 6, Maehle 7; Pessina 6, Zapata 6, Ilicic 7.
Subs: Malinovsky 8, Djimsiti 6, Muriel 7, Zappacosta 6.
Villarreal: Rulli 7; Foyth 7, Albiol 6, Pau Torres 7, Estupinan 6; Maxi Gomez 7, Capoue 7, Parejo 7, Moreno 6; Gerard Moreno 7, Danjuma 8*.
Subs: Iborra 6, Pedraza 6, Dia 6, Trigueros 6, Pena 6.
3' GOAL FOR VILLARREAL! Atalanta are playing with a very high line and a simple ball forward put Danjuma through on goal and he raced half the length of the field before nutmegging the keeper and putting his side in front.
42' GOAL FOR VILLARREAL! Lovely intricate football around the box from the Yellow Submarine with Capoue squeezing a ball through to Moreno who plays it wide to Moi Gomez. His pass back into the area is taken by Capoue and he crashes the ball inside the near post.
52' GOAL FOR VILLARREAL! Moreno beats Palomino with a nutmeg and then crosses for Danjuma who turns and puts the ball in the net as Musso dives the wrong way.
58' Off the bar! A fantastic free kick from the left edge of the penalty area from Malinovsky but it deflects off the outside of the upright. The keeper would have stood no chance
71' GOAL FOR ATALANTA! Why wasn't he on from the start? Malinovsky fires home from the edge of the box to get his side back into the game. Kind of...just another three required.
80' GOAL FOR ATALANTA! It couldn't happen, could it? Zapata is played through on goal by Ilicic and he dinks the ball over the goalkeeper and it rolls just over the line.
86' Muriel shoots against the post from outside the box and the rebound hits Toloi's thigh and agonisingly goes wide of the target.
Atletico labour to draw against Villarreal after brilliant Correa goal
Abraham hits brace as Roma crush Atalanta to stay in Champions League race