Max Stryjek was the Livingston hero as he saved two penalties to send the Lions into the Premier Sports Cup quarter-finals.
The Polish stopper's late fumble last week against Aberdeen saw Livi fall to defeat in the league but he redeemed himself in fine fashion against St Mirren with a fine display that included two tremendous saves during the first-half.
Alan Forrest had given the hosts a 41st minute lead when he cut in from the right to curl into the far corner. Livi looked to have held on for the win, only to concede nine minutes from time when Connor McCarthy slammed home from close range after a Scott Tanser free-kick fell kindly to him.
There was a moment of controversy in the second half of extra-time when Nicky Devlin appeared to poke the ball over the line prior only for the officials to say otherwise.
The home side had the early advantage in the shoot-out as Curtis Main fired St Mirren's first spot-kick wide before misses from Keaghan Jacobs and Craig Sibbald - put the Lions under pressure.
Stryjek saved from Cammy MacPherson before diving low to his left to get both hands on Kyle McAllister's sudden death effort after Jason Holt had slotted home for Livi as last year's beaten finalists progressed.
Livingston had handed a debut to new signing Odin Bailey, while there was a place on the bench Harrison Panayiotou who signed on Thursday having spent the last two seasons with English National League side Aldershot Town.
The most important team news for the Lions, though, was the return of the club's all-time record appearance holder Keaghan Jacobs with the South African midfielder making his return from a 17-month lay-off with a foot injury.
The hosts had the game's first chance when Scott Pittman collected the ball just inside the St Mirren half four minutes in. He drove forward into space but his strike from 18 yards out was straight down the throat of Jak Alnwick in the Buddies goal.
Two minutes later, Scott Tanser fashioned a chance for the Buddies down their left-hand side but dragged his effort harmlessly wide of the woodwork.
Bailey, signed on loan from Birmingham City, looked a tricky customer on the wing for the hosts and he came close to opening his account on 14 minutes. Neat link-up play by the Lions saw Forrest tee up the debutant, who saw his curling strike from the edge of the box go agonisingly wide.
Livi keeper Max Stryjek made a decisive error in last weekend's league clash with Aberdeen but showed his value to the side midway through the first half with a brilliant save from Greg Kiltie. The former Kilmarnock man had all the time in the world to fire home from 15 yards after Tanser's cross had been half-cleared by Ayo Obileye, but the Polish stopper kept the game scoreless with a terrific save to his left - before dealing with an altogether more comfortable strike from distance by Eamonn Brophy moments later.
For all the effort and determination on show, the game lacked quality - that is until Forrest's 41st minute strike. Craig Sibbald won the ball in midfield as the Lions launched a counter-attack. He found Pittman who released Forrest down the left flank. Last season's League Cup top scorer got his account up and running in typical fashion as he cut inside and curled a wonderful effort beyond the diving Alnwick.
Barely a minute later, Stryjek was called into action as Brophy raced clear, only for the keeper to race from goal and produce a stunning stop to keep his side in front.
Livi passed up a great chance to stretch their lead just five minutes into the second half when Obileye met a Forrest corner, but the big defender couldn't get underneath the ball as he headed over from 10 yards out.
There was little in the way of great attacking football after the interval with countless attacks from both sides breaking down inside the final third thanks to a poor pass or wrong decision being made.
That made it all the more galling for the home side when slack defending from a free-kick resulted in the visitors levelling things up nine minutes from time. The ball found Connor McCarthy inside the six-yard box with the defender slamming home from close range.
The momentum completely turned and St Mirren had the ball in the net a second time a minute later - only for Curtis Main to be flagged for offside as he fired across Stryjek and into the far corner.
Having weathered that storm, Livi went searching for the winner - and it almost arrived right at the death. Substitute Jack Hamilton saw his curling strike deflected narrowly wide in the fifth minute of injury-time, while Jack Fitzwater headed over under pressure from the resulting corner as the game headed for extra-time.
The additional 30 minutes was a war of attrition between two tiring sides. The hosts had strong appeals for a goal turned down on 109 minutes when Andrew Shinnie's corner-kick eventually fell to Nicky Devlin, with the Livi skipper seemingly prodding the ball over the line before only for David Munro to remain unmoved as Alnwick held on.
That was the only real chance of note in extra-time as the two sides had to be separated by penalties - with Stryjek being the home team hero.
Livingston: Stryjek; Devlin, Obileye, Fitzwater, Longridge (Jacobs 103); Holt, Pittman, Sibbald; Bailey (Kelly 62), Anderson (Panayiotou 67; Shinnie 78), Forrest (Hamilton 66). Subs not used: Barden, Reilly, Bartley.
Goal: Forrest (41).
St Mirren: Alnwick; Fraser (McAllister 72), Shaughnessy, Dunne (McCarthy 27); Tait (Henderson 58), Kiltie (MacPherson 58), McGrath, Erhahon, Tanser; Main, Brophy (Erwin 90). Subs not used: Lyness, Flynn, Finlayson, Jack.
Goal: McCarthy (81).