Blaine Hudson's late winner gave The New Saints a narrow lead in their Europa League second qualifying round tie with Gibraltar's Lincoln Red Imps.
The defender timed his run at the back post perfectly to meet Aeron Edwards' header back across goal.
Dean Ebbe gave the hosts the perfect start when he converted Jamie Mullan's pull-back for the opener.
But Joseph Chipolina headed Imps level before half-time, finding space between two defenders from a free-kick.
Imps - who famously beat Celtic in 2016 - will be delighted to have that away goal to take from Park Hall for the second leg on Thursday, 2 August.
Saints were not at their best and the Welsh champions could have given themselves more breathing space in the tie.
Daniel Redmond should have scored midway through the second half but saw his effort cleared off the line, after Greg Draper had done well to make space before cutting the ball back.
New Zealand striker Draper - who had replaced the injured Ebbe before the break - had earlier gone close himself but saw his shot well saved by Imps goalkeeper Manuel Soler.
Saints dropped into the Europa League after they were knocked out of the Champions League by Macedonian side Shkendija.
Having lost 5-0 in the away leg, Saints won 4-0 in an extraordinary second-leg comeback at Park Hall but fell just short.
The Welsh champions at least have a lead to take into a European second leg this time, with the winners facing Astana or Midtjylland in the next round.
New Saints manager Scott Ruscoe told BBC Sport Wales: "We got that second goal... not luckily, we did enough to win the game.
"But we're not going over there next week thinking this tie is over, it's far from over.
"We need to start again on the front foot; we're always looking to get goals which we can do from anywhere on the pitch... and we're going to give it a right go and make sure we manage the game properly."
The New Saints
- 10RedmondSubstituted forCieslewiczat 88'minutes
- 17EbbeSubstituted forDraperat 40'minutes
Lincoln Red Imps
- 1Soler Ortuño
- 8Moreno CerrilloBooked at 75mins
- 3ChipolinaBooked at 76minsSubstituted fordos Santosat 84'minutes
- 9VincueriaSubstituted forOrtiz Jiménezat 64'minutes
- 28Gámiz Maroto
- 21Montesinos Romero
- 23ParísSubstituted forAnnesleyat 65'minutes
- 15dos Santos
- 18Corral Valero
- 19Calderón Vallejo
- 99Ortiz Jiménez
- Thorvaldur Arnason