Kyogo Furuhashi's early goal proved crucial as Celtic reached the Europa League group stage despite a torrid night in Holland.
Celtic gifted AZ Alkmaar two extremely soft goals before hanging on for a 3-2 aggregate victory, losing 2-1 on the night.
Ange Postecoglou's side went three up on aggregate with little over two minutes gone. Anthony Ralston's ball over the top sent Liel Abada clear and the winger squared for Furuhashi to knock home his seventh goal for the club.
The good work was undone three minutes later following a blunder by Joe Hart and the hosts were soon 2-1 ahead following Carl Starfelt's own goal.
There were more nervy moments in a breathless encounter and Celtic suffered a blow ahead of Sunday's trip to Ibrox to face Rangers when Greg Taylor suffered an early shoulder injury.
But the job was ultimately completed as Celtic moved into Friday's draw and avoided dropping all the way down from the Champions League to the third tier of European competition.
The opening six minutes set the tone for a frantic encounter.
Celtic looked to have taken the sting out of the tie when Furuhashi netted, but a long kick out from the home goalkeeper led to an equaliser. Stephen Welsh did not get as much on his chest back to Hart as he would have wanted, but the goalkeeper was still a clear favourite to get the ball.
However, Hart stood and waited for the ball to arrive and Zakaria Aboukhlal won the ball in a challenge on the edge of the box before finding an empty net.
Taylor went off in the 24th minute after failing to shake off a shoulder injury and Adam Montgomery was preferred to Boli Bolingoli as the left-back's replacement.
AZ right-back Yukinari Sugawara twice fired wide from outside the box before his cross led to his side's second goal in the 26th minute. Starfelt was under no pressure at all in the six-yard box, but he missed his kick with his left foot and saw it spin off his right leg and into the net.
Teun Koopmeiners shot just wide from 18 yards after Callum McGregor was caught in possession before Hart made a good save after Aboukhlal got in behind.
The interval did nothing to alter the relentless pace of the game and Welsh came to Celtic's rescue twice inside the opening three minutes of the second half.
Hart made another decent save from Aboukhlal before the introduction of Odsonne Edouard brought an element of calmness to Celtic's play, and both Ryan Christie and Montgomery had shots diverted wide.
But Hart gave the hosts some fresh impetus by making a poor decision to come for an aerial ball and eventually conceding a corner which Bruno Martins Indi headed wide from a great opportunity.
The closing stages were fraught for the visitors and Ernest Poku missed the best chance to take the tie into extra time when he missed the target from six yards after sliding in to meet a low cross.
Postecoglou only added another defensive midfielder in the 86th minute when Ismaila Soro came on for the goalscorer, and Celtic hung on.