The Saints, desperate to put their woeful league form behind them, were first to threaten after five minutes when Stevie Mallan sent a raking pass through to John Sutton.
Sutton scored for the Paisley side in the only previous cup meeting between the sides, a 3-0 win in 2006, but there was to be no repeat, his thundering 16-yard angled drive sailing over the crossbar.
The championship side were dominant in the early exchanges, enjoying the bulk of possession and putting Spartans under extreme pressure.
After ten minutes, Lawrence Shankland exploited space in midfield to thread the ball through to the overlapping Jason Naismith, but his driven cross was cleared brilliantly by Chris Townsley, with Sutton breathing down his neck.
Spartans were starved of the ball, but set their stall out with a steely determination to frustrate Jack Ross’s side, limiting the hosts to long-range efforts until Saints finally made the breakthrough in 15 minutes.
The impressive Kyle Magennis showed skill and vision to pick out a superb pass to Shankland, bursting in from the right. He looked up and curled a superb, left-foot shot high into the net from 15 yards.
Four minutes later, the Saints doubled their lead when Kyle McAllister sent Naismith down the right. His cutback found Mallan 25 yards out and the midfielder ran on to the ball to crack a wonderful shot high into the net past goalkeeper Blair Carswell.
The part-time Edinburgh side were ripped apart for a third time in 32 minutes with a goal of sheer class from teenager McAllister, who jinked his way downfield, leaving three players in his wake, before sending a shot high past Carswell from 18 yards.
Two years ago, the last time Spartans faced Renfewshire opposition in the cup, they shocked Jim Duffy’s Morton. But against a Saints side determined to kick-start their season – they are adrift at the bottom of the championship – a shock never looked on the cards for the Edinburgh side.
Saints were relentless and continued to torment the Ainslie Park outfit, and, five minutes from the interval, Mallan almost added a fourth when he got in front of Spartans captain Eddie Malone, but his 20-yard effort drifted wide.
Such was Saints’ dominance that Spartans didn’t even manage a shot off target in the first period, let alone trouble Paisley goalkeeper Scott Gallagher.
Spartans, in a bid to revive their hopes, brought on Scott Maxwell at the break for Andrew Mair, who had little service in attack in the first period.
Saints began the second half in the same positive manner and, after 51 minutes, Lewis Morgan burst down the left and cut the ball back perfectly for Sutton, but Carswell got down well to save from his shot from 12 yards..
The brave Spartans fans who made the trip through to Paisley finally had something to cheer in 56 minutes when Paul Thomson launched a high cross which goalkeeper Gallagher flapped at under pressure from Jack Hay, but Alan Brown’s follow-up was cleared off the line by Ben Gordon.
Carswell was in action again in 58 minutes, saving from Mallan’s low 18-yard shot. But he could do nothing about Saints’ fourth in 63 minutes when Sutton knocked home a rebound from close range. Everything was going Saints’ way.
Shankland got his second and Saints’ fifth when he ran on to a Sutton pass and clipped the ball over Carswell with ease.
Spartans got some consolation in 73 minutes when Jack Beesley knocked home the rebound after Gallagher had saved from Jamie Dishington.