Striker Gary Hooper opened the scoring in the 21st minute when he capitalised on a mistake by Spartak defender Juan Insaurralde but that lead was cancelled out in the 39th minute by Ari, after good work by the impressive Emmanuel Emenike.
But the Scottish champions were not to be denied and, after defender Marek Suchy conceded a penalty in the 80th minute for a clumsy barge on Georgios Samaras, up stepped Commons to slam the ball in off the bar.
Two minutes from time Spartak midfielder Kim Kallstrom picked a second yellow card for a foul on Commons who was taken off on a stretcher, but Neil Lennon's side finished second in Group G behind Barcelona with 10 points and are in the knockout stages for the first time since the 2007/08 season.
The Scottish champions went in to the game knowing they would qualify for the knockout stages only if they got a better result against Spartak, consigned to the bottom of the table, than Benfica got in the Nou Camp.
In the 12th minute visiting captain Dmitri Kombarov's cross from the left almost found the lively Emenike while Kallstrom played a smart one-two with Artem Dzyuba before curling a left-footed shot from 25 yards just past Fraser Forster's right post.
The Moscow club only had themselves to blame for falling behind. Insaurralde attempted to cut out a through ball but succeeded only in taking the sting out of the ball, allowing Hooper to drill the ball low into the corner from outside the box.
After the half-hour mark Hoops skipper Scott Brown had a first-time effort from 16 yards saved by Sergei Pesyakov but Spartak's equaliser, when it came, was well deserved. Emenike bounced his way through several attempted tackles before laying the ball wide to Ari whose chip beat Forster.
Celtic started the second half with purpose and in the 50th minute Samaras came close with an effort which struck the post. In the 72nd minute Efe Ambrose headed a Commons corner into the side-netting with some Hoops fans thinking the ball had gone in.
In the 80th minute Celtic were handed their lifeline when Suchy barged Samaras in the box and Commons hammered the ball high past Pesyakov and in off the bar. After Kallstrom was dismissed, Commons' departure meant Celtic, played five minutes added time also with 10 men but saw out the win.
Source: PA
Source: PA