Mohamed Salah's late strike earned Basel a 1-0 win and a second straight Group E victory over the 2012 champions, who are guaranteed a top-two finish after Schalke only drew with Steaua Bucharest.
"A bad performance, a deserved defeat. But because of other results, we qualify," said Chelsea manager Jose Mourinho, whose side joined Barcelona, Bayern Munich, Manchester City and Atletico Madrid in the round of 16. "That is the only positive thing from this night."
Milan cruised past Celtic 3-0 but still needs a point against Ajax in their last match after the Dutch side upset already-qualified Barcelona 2-1 to keep alive its last-16 hopes alive.
A draw on the final matchday will also be enough for Arsenal to advance as group winners after Jack Wilshere scored twice in the 2-0 win over Marseille in London.
With Napoli losing 3-1 to Borussia Dortmund elsewhere in Group F, both teams lie three points behind the English side. Arsenal finishes group play against Napoli and will progress for the 14th straight season by avoiding a three-goal defeat in Italy.
"It's an interesting one, a difficult one, but we have played other difficult games away from home against difficult opponents and have done well so that's what we have to put in our mind," Arsenal manager Arsene Wenger said.
In Group G, Zenit St. Petersburg and FC Porto were left to compete for the second qualification spot behind Atletico after both earned 1-1 draws on Tuesday.
Zenit relied on an 74th-minute own goal by Atletico defender Toby Alderweireld to hold the Spanish side in Russia and stays a point ahead of Porto, which also scored a second-half equalizer through Jackson Martinez to draw with Austria Vienna.
It ended up being a bittersweet evening for Chelsea, which has sailed through its group with three straight victories since opening up with a 2-1 home loss to Basel.
Chelsea knew a point would be enough to advance and that appeared to hold back Mourinho's team, which failed to have a shot on goal before Salah sprinted clear of Chelsea's defence to clip a left-foot shot over the advancing Petr Cech in the 87th minute.
"I did not like anything from the first minute," Mourinho said.
As the holder, Chelsea failed to reach the knockout stage last year, albeit from a much harder group than this season.
Six months after losing to Bayern in the final, Dortmund wouldn't have even got out of its group if it had lost to Napoli but Marco Reus' penalty and strikes by Jakub Blaszczykowski and Pierre-Emerick Aubameyang revived the German side's hopes.
"It was a match to remember," Dortmund coach Juergen Klopp said.
Dortmund completes the group with a trip to Marseille, which is seeking to avoid a sixth straight defeat after slumping at Emirates Stadium courtesy of goals either side of halftime by Wilshere.
The England midfielder's first came after just 29 seconds before adding another in the 65th minute, by which time Mesut Ozil had missed a penalty.
"We're not through yet — we have to regroup again," Wilshere said. "It's a tough group."
It will be a winner-takes-all match at the San Siro in two weeks as Milan's victory in Glasgow was matched by Ajax's surprise triumph over Barca.
Kaka and Cristian Zapata pounced on two pieces of poor defending at corners by Celtic to score in the 13th and 49th minutes for Milan, before Italy striker Mario Balotelli wrapped up victory in the 59th.
Meanwhile, Barcelona's unbeaten run — that started last season — finally came to an end in Amsterdam after 25 matches.
Ajax took a well-deserved two-goal lead by the break thanks to strikes from Thulani Serero and Danny Hoesen but was forced to hang on for the three points after Joel Veltman was sent off for bringing down Neymar in the area, earning Barcelona a spot kick that Xavi Hernandez calmly converted.
"You can only dream about this," Hoesen said. "They are probably the best team in the world and to be able to score the winning goal is amazing."
Barca was missing the injured Lionel Messi and fielded a makeshift backline with full backs Jordi Alba and Dani Alves and goalkeeper Victor Valdes also absent.
The Champions League resumes on Wednesday, when Real Madrid, Paris Saint-Germain and Manchester United can all qualify.