Thierry Henry struck in stoppage-time to cement Arsenal's place in the second round of the Champions League with a 3-1 win against Real Mallorca.
Progress beyond the first group stages for the second year running looked a formality when Robert Pires and Dennis Bergkamp scored within two minutes of each other just past the hour.
Arsenal needed Bergkamp's emphatic header to surpass Mallorca on the head-to-head countback after the Spaniards beat them 1-0 in Palma last month.
But they were in dire danger of having to go to Germany and prise a point from Schalke next Tuesday after Mallorca halved the deficit with a goal out of the blue through Alvaro Novo with 15 minutes left.
Suddenly all Arsenal's inconsistencies this season surfaced and Richard Wright, previously unemployed, made a series of desperate saves to prevent Arsenal going out.
But just when the Gunners seemed set for another right-to-the-wire job next week, Giovanni van Bronckhorst's quickly-taken free-kick caught Mallorca cold.
Henry ran completely clear of the Mallorca defence and converted his 13th goal of the season - after spurning a hat-trick of earlier efforts.
Arsenal tore and probed at the heavily-manned Mallorca defence almost non-stop in the opening 45 minutes - but it was the old story of failure to convert even one of a litany of scoring opportunities.
Bergkamp spurned an early chance to lift his shot over goalkeeper Leo Franco and it set the trend for a series of off-target efforts.
Patrick Vieira, running the midfield in the absence of injured Mallorca stars Vicente Engonga and Ariel Ibagaza, connected solidly with a square pass from Pires 20 yards out to force an athletic save by Leo Franco in the 22nd minute.
Then Henry drifted casually past two defenders a minute later - only to produce a tame shot which Franco comfortably collected.
Bergkamp's searching cross from the right finding Pires perfectly placed in the area for a 33rd-minute shot but the Frenchman elected to turn the ball back for Henry - and the striker could not dig it out from under his feet.
A misjudgement by Lauren allowed Veljko Paunovic to get in a cross from the left which flashed, untouched, across the Arsenal goalmouth.
Arsenal responded with a probing run on the right by Ljungberg whose splendid cross was sidefooted inches wide by Henry.
Bergkamp was desperately unlucky after going past two defenders on the right before seeing his marvellous angled chip shot float over Leo Franco but drop just the wrong side of the far post.
Fifteen more frustrating second-half minutes ebbed away before the breakthrough came when Pires who had rolled tamely wide just seconds earlier, drove inside Franco's near-post after Ljungberg's crossed flashed over Henry's leap.
It looked all over soon after when Bergkamp thumped in an emphatic header following an electric run on the left by van Bronckhorst.
But Mallorca jumped back into contention when Camparoi - who had missed two half-chances - set up Novo for a run past Campbell and a swerve beyond Wright to tuck into an empty net.
Kanu, finding it hard to believe he was flagged offside, shot wide of a gaping goal in the 90th minute and then Pires had an effort disallowed for offside.
It looked like anguish again for the Gunners in Europe. Then came Henry.