After Stevie May had given the Scottish Cup holders a 42nd-minute lead in the second leg of their third qualifying round clash from the edge of the box, the Perthshire club were just one goal away from reaching the next stage.
However, eight minutes from time an error by the visiting defence allowed Martin Mikovic to grab an equaliser and knock out Saints.
After losing the home leg at McDiarmid Park 2-1, St Johnstone needed a strong start and the visitors brought a couple of good saves out of goalkeeper Dobrivoj Rusov.
First he blocked a Dave Mackay header, then kept out an effort from May.
At the other end, Alan Mannus saved a long-range shot from Jan Vlasko before Rusov produced a brilliant save to deny May once again.
The hosts came mighty close just after the half-hour mark when an Ivan Schranz header hit Mannus and deflected over the bar.
But shortly before the break Tam Scobbie laid the ball off to May whose left-foot strike from 20 yards took a massive deflection before nestling in the corner of the net.
The equaliser came courtesy of an error by Gary Miller whose attempted clearance was headed straight into the path of an unmarked Mikovic who fired Spartak level.