The hosts created the first real opportunity when Gregg Wylde sent over a left wing cross into a dangerous area but Steven Thompson was inches away from getting the vital touch.
However, it was the Pars who grabbed the lead in the ninth minute after the Saints defence failed to clear a Josh Falkingham free-kick and the ball fell into the path of Lewis Spence, who fired a low effort into the bottom right hand corner of the net.
Some textbook dribbling inside the Dunfermline penalty area from Adam Drury was followed by a shot from the on-loan forward which blasted off the crossbar as the Premiership side sought an equaliser.
Craig's men almost gifted the visitors a second goal when Jason Naismith was slack with a header back toward Kello, which was intercepted by Moffat only for the Saints full-back to force the ball out of play.
On the verge of half-time Ryan Scully in the Dunfermline goal very nearly gifted the Paisley men an equaliser after he parried a Wylde shot into the path of Jeroen Tesselaar, only for the Buddies midfielder to blast his shot past the right hand post.
Craig made two alterations at the break, In an attempt to try and inject some much needed verve into his team's play. The lumbering Steven Thompson and pedestrian debutant Isaac Osbourne were replaced by Calum Ball and Caldwell respectively.
The introduction of Caldwell paid off within minutes as the diminutive St Mirren man cut in from the left, evaded a couple of half-hearted challenges and netted his first goal of the campaign in all competitions in the 50th minute.
However, the team from the third tier of the league came close to getting their noses in front again - only for Chiguzie Ogwu to be denied by a smart stop from Kello after an assist from Ryan Thomson.
St Mirren came close to a goal when Naismith was inches away from getting on the end of a Drury ball, before Caldwell was denied by a block from Scully.
Kenny Mclean was next to try his luck, only to shoot straight at the goalkeeper as the top flight team threatened to turn the screw on Dunfermline.
Pars livewire Falkingham produced some excellent skill outside the box before firing a shot which went inches wide, before the Buddies grabbed the all-important third goal of the game.
With 11 minutes remaining on the clock and the Saints piling on the pressure, man of the match Caldwell found himself free in the Pars box - and he made no mistake, rifling home to send his team into the next round.