Qualifying due to their Svenska Cupen victory in May, Hacken was among the unseeded teams in the First Round and faced pressure in a first half where they lost Adam Lundqvist to injury early on.
The home team created four shots in the first 45 minutes compared to Hacken's none, but Spartak failed to challenge Etrit Berisha in the visitors' goal.
Tempers flared early in the second half, resulting in several yellow cards, before Hacken capitalized on Trnava's lack of effectiveness in the first half, as Severin Nioule broke the stalemate shortly after the hour mark.
That was one of only two shots on target the visitors managed throughout the game, but it was two more than Spartak could produce, giving the Getingarna a 1-0 advantage to take back to Gothenburg.
The second leg is scheduled for next Thursday at the Bravida Arena, with a two-legged matchup against Belgian giants Anderlecht awaiting the winners in the Second Qualifying Round.