Celtic progressed into the Champions League group stage as expected with an 8-4 aggregate win over Astana, but they were made to sweat in their 4-3 second-leg defeat in Kazakhstan.
The Hoops' progress was never in serious doubt following their 5-0 thrashing of the Kazakhstan champions at Parkhead last week, but there were some nervy moments for the Scottish champions as they slipped to a first defeat of the season in a pulsating encounter at the Astana Arena.
Celtic's 19-year-old defender Kristoffer Ajer, in for injured Jozo Simunovic, deflected a shot from defender Dmitri Shomko past goalkeeper Craig Gordon in the 26th minute to give the Kazakh side the merest glimmer of hope, quashed, it appeared, eight minutes later when Hoops attacker Scott Sinclair curled in the equaliser.
Two goals in a minute at the start of the second-half from attackers Serikzhan Muzhikov and Patrick Twumasi brought the home side back to life and, when Ghanaian Twumasi grabbed his second, the visitors were on the ropes.
However, late goals from Olivier Ntcham and Leigh Griffiths confirmed Brendan Rodgers' side's passage into the group stages for the second successive season.
The Northern Irishman was again forced to start with a makeshift central defence due to injuries.
Nir Bitton, essentially a midfielder, had passed a fitness test on an ankle injury and the midfielder was paired with Ajer, who had played in the 2-0 win over Kilmarnock at Rugby Park on Saturday.
The only other Celtic change from the first leg saw midfielder Callum McGregor take over from Tom Rogic, who started on the bench.
If anything, the Scottish champions looked more like getting the first goal than their hosts in the early exchanges.
Twumasi drilled a shot from 20 yards just past the post in the 10th minute but it was not the whirlwind start a side needing five goals might have been expected to make.
Sinclair and McGregor both had good efforts as Celtic moved with menace.
The home side got in front slightly against the run of play when Shomko edged towards the Celtic box and drilled in a left-footed drive which came off Ajer leaving Gordon with no chance.
Astana's supporters were energised with optimism but that should have been extinguished seconds later when Sinclair burst through the fragile Kazakh defence only to blast his shot against home goalkeeper Nenad Eric.
However, the former Manchester City and Aston Villa player was so much more accurate in the 33rd minute when, from the edge of the box, in trademark style, he curled the ball high past the Astana stopper and into the far corner before running to take the acclaim of the couple of hundred Hoops fans who had made the long journey east.
Both sides continued to go forward. Moments later James Forrest headed a Kieran Tierney cross past the near post before Gordon brilliantly tipped a powerful header from Marin Anicic over the bar following a Muzhikov corner.
Muzhikov's early second-half goal came after an uncharacteristic mistake by Scott Brown in giving away possession then heading a cross on to the Astana player who poked the ball in from close range.
A minute later the unmarked Twumasi headed a Shomko cross past Gordon and suddenly some hope was restored although four more goals were required.
Rodgers replaced McGregor with Rogic and Forrest with teenage defender Anthony Ralston before Stuart Armstrong came on for Sinclair.
Griffiths missed a great chance when he controlled a Tierney cross on his chest before thrashing the ball over the bar and looked further aghast seconds later as Twumasi raced in from the right and squeezed the ball past Gordon from a tight angle.
There was bedlam among the home fans.
Eric made a fine save from Griffiths' free-kick just before Gordon prevented Twumasi and Muzhikov adding further to Astana's lead.
Twumasi then blazed over the bar from 10 yards with the Hoops defence reeling but, on an 80th-minute breakm Ntcham steered a shot past Eric which allowed everyone of a green and white persuasion to breath more comfortably.
Griffiths, with two minutes of regulation time remaining, then helped himself to a goal on the break with a fine angled-drive.