Owen Coyle's side moved into the second round of the Challenge Cup after a penalty shoot-out.
St Johnstone were overjoyed to scrape through
Saints took the lead in 14 minutes when Marvin Andrews was adjudged to have pushed David Weatherston in the box. Paul Sheerin scored from the spot.
Raith equalised when Andy Tod headed home from Robert Sloan's corner - but were reduced to 10 men when Chris Silvestro was shown a second yellow.
Alan Main was Saints' hero as he saved penalties from Jason Darling and Tod.
Raith Rovers: Renton, Wilson, Pelosi, Tod, Andrews, Silvestro, Borris (Darling 113), Winter, Hislop (Campbell 21), Weir, Sloan. Subs not used: Dingwall, Helley, Amos.
Sent Off: Silvestro (90).
Booked: Silvestro, Campbell, Weir.
Goals: Tod 89.
St Johnstone: Main, Lawrie, Stanic, McInnes, McManus, Anderson (Dyer 115), Weatherston, Hardie, Stewart (Daal 60), McCluskey (MacDonald 60), Sheerin. Subs Not Used: Jackson, Cuthbert.
Booked: McManus, Hardie, McInnes.
Goals: Sheerin 14 pen.
St Johnstone win 5-4 on penalties Att: 1,801
Ref: C Boyle