On a day when the swirling wind made life impossible for both sides at times, Perth midfielder Gary McDonald opened the scoring in the third minute only for Rovers midfielder Joe Cardle to level in the 21st minute with a 30-yard pile driver.
Saints forward Nigel Hasselbaink restored the Scottish Premiership side's lead in the 49th minute with a toe-poked shot before defender Steven Anderson made sure of their place in Sunday's draw in the 78th minute with a third.
The lunchtime kick-off for a quarter-final tie live on television attracted just 3,767 fans and they were just settling down when St Johnstone took the lead.
Raith defender Paul Watson blatantly barged Stevie May in the centre circle and when Gary Miller hoisted the free-kick high into the Fifers' penalty box, Anderson's fell to McDonald and he turned and rifled a right-footed drive past Rovers keeper Lee Robinson.
It looked like that boost would propel Tommy Wright's side on to a comfortable victory, a perception compounded as the home side struggled to get going.
However, out of the blue Raith found themselves on level terms when Cardle picked up possession and with time and space, he looked up before arrowing a glorious drive past St Johnstone keeper Alan Mannus and in off the post for his seventh goal of the season.
Stunned St Johnstone steadied themselves and regained control with left-back Brian Easton driving just wide of Robinson's left-hand post from 30 yards.
However, Rovers finished the half stronger. Defender Dougie Hill headed a Cardle corner just wide of the target from six yards and Ross Callachan missed an even better chance when he headed a Cardle free-kick past the post when at least he ought to have hit the target.
Raith started the second-half with a sense of purpose and confidence, Cardle flashing an angled-drive wide of the target after capitalising on some slack defensive play by the visitors.
However, four minutes after the restart Saints were back in front and in rather simple style when Hasselbaink sped into the Rovers box before knocking the ball past Robinson.
It was perhaps as unexpected a goal as Raith's leveller but it turned the cup tie back towards Perth. McDiarmid Park midfielder James Dunne fired wide of the target from the edge of the box moments later before Robinson made a good save from May's long-range effort.
However, in the 64th minute Mannus was forced into a decent save from Liam Fox's 20-yard free-kick, reminding St Johnstone that their last-four place was not yet secure.
Dunne almost replicated Cardle's goal in the 77th minute but his long-distance strike just missed the far post by inches but a minute later Saints secured their semi-final berth when Anderson flicked a Lee Croft corner in at the near post with the Rovers defence static.