Dunfermline threatened to dump Premiership Saints out of the League Cup but in the end they ran out of steam.
Ross Caldwell came off the bench for a second-half double to end the Pars’ hopes of a giant-killing act.
Saints, without a win in their opening four Premiership matches and still to find the net, were desperately hoping for the League Cup to kick-start their disappointing start to the campaign under the charge of new boss Tommy Craig, who drafted in Isaac Osbourne to the midfield for his debut.
Things hardly improved when they went a goal behind to the League 1 Pars after just nine minutes.
After a rash tackle by Kenny McLean, Ross Millen floated a free-kick into the area which was weakly headed clear by Ellis Plummer. Lewis Spence, unmarked 20 yards out, sent a crisp right foot volley low into the far corner of the net past goalkeeper Marian Kello.
Jim Jefferies’ side might have doubled their lead on 17 minutes when Ryan Williamson carved an opening for Chigozie Ugwu but Plummer managed to get in a brilliant goal-saving tackle.
Michael Moffat picked up a clever flick from Ryan Thomson three minutes later but his curling long-range effort went just wide.
Saints almost got their first goal of the season in 24 minutes when Gregg Wylde cut the ball low across from the left.
The ball was only half cleared by the hesitant Pars’ defence and Adam Drury pounced but his first-time shot from 12 yards crashed back off the underside of the bar. It summed up the season up to that point for the Paisley side.
The Pars, with an indifferent start themselves to their league campaign after one win in their opening three games, took heart from their early lead and chased down every ball tirelessly, giving the Buddies precious little space to operate in midfield.
Dunfermline always looked threatening on the counter-attack, with Kello forced to punch clear on several occasions.
Even when it looked like relatively untroubled Pars goalkeeper Ryan Scully was going to be called into action in 43 minutes, when John McGinn raced through, Lewis Martin timed his last-man tackle to perfection.
Craig made a double change at the break, bringing on Caldwell and Calum Ball for Steven Thompson, who looked out of sorts, and Osbourne.
The move was to be pivotal when Saints got their long-awaited first goal of the season to draw level on 50 minutes.
Caldwell cut across the edge of the area on to his right foot and from 18 yards dispatched the ball beyond Scully, albeit with the help of a wicked deflection off Gregor Buchanan.
Dunfermline almost regained their lead two minutes later when Ugwu ran on to a pass from Thomson but Kello blocked superbly at his near post.
Chances came thick and fast and Saints might have gone ahead in 58 minutes when Ball burst in from the left but Scully saved superbly at his feet. The Dunfermline keeper produced an even better stop one minute later when Wylde tested him with a ferocious angled drive.
Saints finally got the winner 10 minutes from time when substitute Ball muscled his way through and slipped the ball to his left to Caldwell, who drew the goalkeeper and curled the ball into the far corner of the net from 15 yards.
Attendance: 1,931.