Warren Feeney's side trailed by a single goal from the first leg but did have the advantage of an away goal.
And, for a period, that looked to be proving crucial after Stephen Lowry put the Blues ahead on 34 minutes with a close range finish from David Kee's corner.
However, Spartak levelled on the night nine minutes into the second half courtesy of a low Erik Sabo shot.
The pendulum swung even more in Spartak's favour on the hour after Jakub Vojtuš ran from his own half to beat Ross Glendinning from just outside the six-yard box.
Spartak were reduced to ten men on 80 minutes after Milan Bortel picked up a second booking but, just four minutes later, the visitors extended their advantage with Sabo doubled his tally.
Linfield: Ross Glendinnnig, Hegarty, Haughey, Waterworth, Lowry, Bates, Burns, M. Clarke, Kee, Reece Glendinning, Sproule subs Deane, Millar, Ward, Mulgrew, Wallace, Quinn, R. Clarke
Spartak Trnava: Jakubech, Vojtuš, Mikovič, José Casado, Bortel, Tóth, Čonka, Sabo, Halilović, Harba, Greššák subs Strapák, Steinhübel, Báez, Košťál, Mikinič, Jirka