The third qualifying tie had swung towards Brendan Rodgers’ side after the 1-1 draw in Kazakhstan and striker Leigh Griffiths, who levelled in the Astana Arena, scored from the spot on the stroke of half-time before substitute Agim Ibraimi levelled with an opportunist long-range effort.
However, in stoppage time, French forward Dembele, on for James Forrest, slammed in a penalty after he had been tripped by Igor Shitov, who was sent packing by Romanian referee Istvan Kovacs for a second booking, with Dmitri Shomko following him amid the mayhem.
It was a crazy end to the match but the Scottish champions go into tomorrow’s play-off draw looking for a favourable tie which will see them into the competition proper for the first time in three seasons.
An elated Rodgers, who kept faith with Irish defender Eoghan O’Connell, said: “We thoroughly deserved to go through.
“They were absolutely brilliant. They showed their fitness in the game, all the work they’ve been putting in.
“We showed wonderful composure, great team spirit.”
The visitors were on the back foot in the early stages.
However, the minutes ebbed with visiting keeper Nenad Eric seeing little action although a 20-yard snap-shot from Griffiths midway through the first-half cleared the far post but not by much.
Celtic suffered a blow on the half-hour mark when winger Patrick Roberts went off after picking up an injury to be replaced by midfielder Stefan Johansen with Forrest moving to the right and Armstrong switching to the left.
Three minutes from the break the former Dundee United midfielder found a yard of space in the Astana box but his drive from 12 yards was smothered by Eric, before defender Yuri Logvinenko blocked a goal-bound Griffiths effort.
However, with the last kick of the first-half amid some drama, the home side got the breakthrough.
When defender Abzal Beysebekov clumsily fouled Tierney inside the box as they challenged for a bouncing ball, Romanian referee Kovacs pointed to the spot.
After a delay, Griffiths took great delight in smashing the spot-kick past Eric.
The goal lifted the home crowd and they went for number two from the restart.
Only a perfectly-timed tackle from Shitov foiled the hosts but slowly the Kazakh club began throwing players forward in search of an equaliser.
Roger Canas had the ball in the net in the 56th minute but the assistant’s flag was up to the relief of the Hoops fans but there was despair around the corner.
On the hour mark Kolo Toure replaced Armstrong to make his debut but moments later it was all square.
Gordon raced outside his box to head clear a through ball and although it went a decent distance, Ibraimi, on for Azat Nurgaliyev controlled the ball and quickly sent it soaring into the empty net.
The game stretched further. Shitov, booked in the first half, was lucky to escape punishment after a foul on Griffiths but he got his just reward for a trip on Dembele who became the Parkhead hero by despatching the penalty.
Gordon, Janko, Lustig, O’Connell, Tierney, Brown, McGregor, Armstrong (Toure 61), Roberts (Johansen 32), Forrest (Dembele 75), Griffiths.
Eric, Anicic, Muzhikov, Nurgaliev (Ibraimi 56), Shitov, Beisebekov, Logvinenko, Shomko, Canas, Twumasi, Kabananga.
Istvan Kovacs (Romania).