Two goals from Ivan Schranz either side of half-time left the Scottish Cup winners facing an uphill struggle for next week’s second leg in Slovakia.
However, captain Dave Mackay’s late goal gave Saints some hope against Spartak who finished third in the Slovakian league last season.
The Perth side were hit by a massive blow just before kick-off when top striker Stevie May, who scored 27 goals last season, was ruled out with a thigh injury.
Slovakia Under-21 international Schranz tested Alan Mannus with an early effort and from the resulting Jan Vlasko corner, the towering Schranz was denied a second time by the keeper, who managed to tip his header onto the bar.
Spartak opened the scoring on 34 when Marek Janecka slipped the ball to Schranz and the 20-year-old found the net, via the underside of the crossbar, with a powerful shot from 15 yards.
The home side got their first shot on target four minutes after the interval but David Wotherspoon’s shot was straight at goalkeeper Dobrivoj Rusov. The attack brought the home crowd to life and Saints carved out another chance six minutes later but Gary Miller could only head wide.
The visitors doubled their advantage when a mistake at the back allowed Schranz (64) to tap in the second from close range after Mannus saved his first effort.
Wotherspoon hit the top of the bar with a powerful late effort before Mackay gave the home side some hope for the next leg when he fired in a low shot in added time.