Celtic completed an 8-4 aggregate win to reach the Champions League group stage despite a scare in Astana.
Leading 5-0 from the first leg, Brendan Rodgers’ side fell behind on the night when Dimitri Shomko’s shot was diverted into the net by Kristoffer Ajer.
And though Scott Sinclair produced a stylish equaliser, Serikzhan Muzhikov and Patrick Twumasi (2) put the hosts 4-1 up with 20 minutes still to play.
But Olivier Ntcham and Leigh Griffiths made the tie safe for the visitors.
It is Celtic’s first defeat in all competitions since losing to Barcelona in Glasgow on 23 November, but they can now look forward to their 10th appearance in the group stage.
The Scottish champions will be in the third or fourth pot of seeds for Thursday’s draw in Monaco.
Should any of Sevilla, Liverpool, Olympiakos or Napoli be eliminated in Tuesday and Wednesday’s play-off ties, Celtic will be in pot three. However, if all four of those sides progress, Rodgers’ men will be in pot four.
The Northern Irishman has now led Celtic to the group stage in each of his two seasons as manager, his side having taken on Barcelona, Manchester City and Borussia Monchengladbach last year.
With Astana faced with such a sizeable first-leg deficit, Celtic may have expected an early onslaught from their hosts in Kazakhstan, but the visitors looked the more incisive early on.
After earlier chances for Sinclair and team-mate Callum McGregor, there seemed to be no imminent danger to Celtic’s lead until Shomko’s speculative shot was deflected by Ajer’s outstretched foot to wrong-foot keeper Craig Gordon.
Astana had restored some belief but their enthusiasm was blunted when Sinclair collected on Celtic’s left, drove at the defence and curled a sumptuous shot past Nenad Eric. It was the Englishman’s third goal of the tie.
The home side needed six more goals at that stage and Marin Anicic’s header was superbly clawed over by Gordon as half-time approached.
Astana capitalised on a poor Scott Brown pass to get ahead early in the second period, Srdan Grahovac’s chipped ball deflecting into Muzhikov’s path for a straightforward finish.
No sooner had Celtic taken the kick-off, they found themselves doing so again. Twumasi was left unmarked to nod in Shomko’s cross.
Junior Kabananga should have converted from the edge of the six-yard box at the end of another flowing Astana move.
Rodgers introduced defender Anthony Ralston in place of McGregor and placed the substitute in a back three with Nir Bitton and Ajer in an attempt to weather the storm.
Griffiths had an excellent chance but got under his shot after chesting the ball down in the box.
Astana scored almost immediately, Twumasi gliding away from the Celtic defence on the right of the box and beating Gordon at his near post.
After Griffiths’ free-kick was saved, Twumasi could have completed his hat-trick when the ball fell to him inside the area, but he got too much elevation on the shot.
Ntcham had been an assured operator in the Celtic midfield and he found the net with the aid of a deflection to ease Celtic’s nerves.
Griffiths put earlier frustrations behind him with a fierce right-foot shot as Astana were again caught on the break.
Stanimir Stoilov’s side restored some pride and can console themselves with the knowledge they will be in the Europa League group stage, the draw for which takes place on Friday.