Three-time European champion Manchester United was eliminated from the Champions League on Wednesday when it lost 2-1 at FC Basel.
Manchester City joined its local rival on the sidelines despite beating Bayern Munich.
United needed to avoid defeat in Switzerland to secure a 15th knockout-round appearance in 16 Champions League seasons. It now drops into the Europa League, facing the likes of Metalist Kharkiv and Legia Warsaw, while Basel advances.
"It's incredible," Basel goalkeeper Yann Sommer said. "A Swiss team, a little country, against Manchester United, one of the biggest teams in the world — it's crazy."
City, the English Premier League leader, also heads into the second-tier tournament despite a 2-0 win over already qualified Bayern. Napoli's 2-0 win at Villarreal took the Italian side through instead.
Lyon won 7-1 at Dinamo Zagreb to complete a remarkable turnaround and qualify ahead of Ajax, which lost 3-0 to Real Madrid. CSKA Moscow won 2-1 at Inter Milan to take the final spot and complete the 16-team lineup for the next round.
After losing three of the last four Champions League finals, United was expected to join Chelsea and Arsenal in the next round after the London clubs progressed Tuesday. But with United defender Chris Smalling lying dazed from a collision with teammate Nemanja Vidic, Basel captain Marco Streller put his team ahead with a ninth-minute shot past goalkeeper David de Gea.
"Manchester are a good team, they had a lot of pressure and sometimes we were a bit lucky not to concede, and this is a crazy night," Sommer said. "We are through and Manchester are out — it's super."
Things got worse for United in the 43rd when captain Vidic was carried off on a stretcher after twisting his right knee while making a challenge. And despite almost constant pressure from United, Basel doubled its lead when Alex Frei scored in the 84th.
United's Phil Jones got a late goal and his team twice hit the crossbar.
Benfica topped Group C with 12 points after a 1-0 win over Otelul Galati. Basel finished with 11 and United was two points further back.
"It's incredible," Basel goalkeeper Yann Sommer said. "A Swiss team, a little country, against Manchester United, one of the biggest teams in the world — it's crazy.
"Manchester are a good team, they had a lot of pressure and sometimes we were a bit lucky not to concede, and this is a crazy night. We are through and Manchester are out — it's super."
City needed to beat Bayern to have any chance of prolonging its first season in the Champions League and did so with ease, scoring a goal in each half, by David Silva and Yaya Toure.
But Gokhan Inler and Marek Hamsik scored second-half goals to secure Napoli's place as the Group A runner-up to four-time European champion Bayern.
Napoli struggled to find a way through the Villarreal defense before Inler launched a 25-yard drive that left goalkeeper Diego Lopez motionless in the 65th minute. Hamsik added a second goal 11 minutes later with a close-range finish.
Napoli finished with 11 points to Bayern's 13. City had 10, while Villarreal became the first Spanish club to suffer six straight group stage defeats.
"We're very sorry for our supporters and I'm sorry for our players," City manager Roberto Mancini said. "I think we need to improve as a team because we got a tough group this year."
Lyon started its match at Dinamo Zagreb three points behind Ajax and needing a seven-goal swing to overturn the Dutch club's advantage on goal difference.
Real Madrid, which was already assured of the top spot in Group D, helped out by completing this season's only perfect first-round record. But Lyon did much of the hard work itself with the rout of 10-man Dinamo.
Things looked bad for Lyon when Dinamo Zagreb overcame the 28th-minute sending off of Jerko Leko for a second yellow card, Mateo Kovacic putting the home side ahead 5 minutes before halftime.
But Bafetimbi Gomis equalized just before halftime and scored another three goals after the break, with Maxime Gonalons, Lisandro and Jimmy Briand adding the others.
Jose Callejon scored twice and Gonzalo Higuain once to give Madrid the win at Ajax, which had two goals disallowed, leaving Lyon tied in points with the Dutch side but ahead on goal difference.
A late winner from Vasili Berezutsk earned CSKA Moscow victory at Inter and a place alongside the home team in the last 16.
Chelsea, Marseille and Zenit St. Petersburg clinched their places on Tuesday, joining already qualified Bayer Leverkusen, Arsenal, APOEL, AC Milan and defending champion Barcelona.
The draw for the last 16 will be held on Dec. 16, with the matches being played in February and March.