French side Lyon pulled off a remarkable Champions League rescue act on Wednesday when they defeated Dinamo Zagreb 7-1 to sneak into the last 16 at the expense of Ajax.
Lyon went into their final Group D game three points behind Ajax and needing to make up a goal difference of seven if they were to reach the knockout rounds.
French international striker Bafetimbi Gomis was the star of the show, scoring four goals, including the fastest ever Champions League hat-trick as Lyon took second place in the group.
Real Madrid, who had already made sure of top spot, downed Ajax 3-0 in Amsterdam to become only the fifth team in the history of the tournament to go through to the next round with a perfect record.
Dinamo had taken the lead in the 40th minute when Fatos Beqiraj cut in from the right and fired a drive at Hugo Lloris who made a double-save but the third attempt fell to 17-year-old Mateo Kovacic who stabbed the ball into the roof of the net.
But Lyon were level just before half-time.
Aly Cissokho's cross looped over Ivan Kelava where Gomis applied the final touch.
Three minutes after the interval, Maxime Gonalons made it 2-1.
Gomis then completed his hat-trick to beat Blackburn Rovers' Mike Newell's record from 1995 for the quickest triple.
First, he hit his second after 48 minutes after Jimmy Briand slid the ball to the striker to fire past Kelava.
He added his third in the 52nd minute off a pass from Gonalons while his fourth of the evening came from a cross by Ederson in the 70th minute to make 6-1, six minutes after Lisandro Lopez had hit Lyon's fifth.
Briand netted the seventh of the night in the 75th minute to complete the rout and put Lyon into the last 16 for the ninth consecutive season.
In Amsterdam, Real notched up a 15th consecutive win in all competitions this season by ending Ajax's hopes 3-0.
Jose Callejon, a product of Real's youth system, grabbed his third goal in three games in the tournament this season, when he opened the scoring in the 14th minute.
The 24-year-old latched on to a fine through pass from Kaka, beat the offside trap and then squeezed the ball through the legs of Kenneth Vermeer.
Argentine striker Gonzalo Higuain, captain for the night in the absence of Iker Casillas, marked the occasion with Real's second, four minutes before the interval.
Fellow striker Karim Benzema was the creator this time, supplying the pass over the top.
Callejon added the third in injury time.