Chelsea lacked both the creativity and quality to break down Brentford, who were happy to soak up the pressure before sealing the win through Bryan Mbeumo's breakaway goal deep into stoppage time.
The result means that Milan now have to win at Newcastle United in the final round of the group while Dortmund must avoid defeat against Paris Saint-Germain to go through.
Saka waltzed through a static Hammers defence to score his second after the break, before Declan Rice made it 6-0 with a rocket of a shot from distance against his former club.
An unfortunate own goal by Levante goalkeeper Diego Marino doubled Madrid's lead four minutes later, only for the hosts to almost immediately pull one back through Brazilian forward Deyverson.
City, needing three points to become champions of England for the seventh time, took the lead just before half-time through Raheem Sterling's close-range strike.
"I didn't know he could break his record tonight, but I'm pretty sure he is proud of that, he should be. An exceptional player, an absolutely exceptional player.
Lisandro Martinez, Jadon Sancho and Raphael Varane were among the other senior players handed a run-out, though ten Hag made major changes at the break.
But Arsenal were pegged back five minutes after the breakthrough Vertessen's right-footed strike off the left post. Both sides had good chances to find a second-half winner.
Eberechi Eze converted from Tyrick Mitchell's cut-back to finish off a flowing Palace move early on and the visitors were deservedly in front at the break.