Scott Quigley's extra-time goal helped The New Saints secure a place in the Champions League second qualifying round as they secured a 3-1 win at Gibraltar's Europa FC, who had two men sent off in the space of as many second-half minutes.
The Welsh Premier League side had been trailing 2-1 from the first leg, but Scott Ruscoe's side levelled the tie on aggregate at the Estadio Algarve after 37 minutes when defender Ivan Moya diverted a free-kick from Ryan Brobbell into his own net.
TNS were still behind on away goals, but edged ahead four minutes before the break when Quigley - also on target in the first leg - turned in Aeron Edwards' pass.
Europa went close themselves ahead of the interval as Jesus Toscano saw his effort hit the woodwork.
The Gibraltar side eventually reduced the arrears on 53 minutes when Liam Walker converted a penalty following handball.
Just two minutes later, though, Europa had forward Kike Gomez sent off for stamping on Ryan Price with Spanish midfielder Alex Quillo then collecting two quick yellow cards from the Belgian referee to leave the Gibraltar side to play out the final half-hour of normal time with only nine men.
Jon Routledge and Jamie Mullan both saw efforts just off target as TNS pushed for a winner, before Brobbell had a 20-yard strike tipped over.
In the first period of extra-time, TNS went close again as substitute Adrian Cieslewicz had an overhead kick cleared off the line.
The Welsh side, though, were not to be denied as, with 104 minutes on the clock, Quigley collected Mullan's pass and dispatched a low shot into the far corner to seal a second-round qualifying tie against Rijeka of Croatia.
UEFA Champions League News
When could Real Madrid win their 100th trophy? Depends who you ask
Real Madrid's UEFA Super Cup triumph was another step toward them becoming the first club in Europe's big five leagues to win 100 official trophies.
Rangers beat Union St.-Gilloise 3-2 on aggregate to keep Champions League hopes alive
Rangers overcame a 2-0 first-leg deficit to beat Union Saint-Gilloise 3-2 on aggregate and progress to the Champions League playoff round.
Champions League to use Semi-Automated Offside Technology from the group stage
UEFA has announced that it will start using the new Semi-Automated Offside Technology (SAOT) from the Champions League group stage this season.
UEFA to investigate Fenerbahce over 'Putin' chant against Dynamo Kyiv in Champions League qualifier
UEFA will investigate Turkey's Fenerbahce after fans chanted Vladimir Putin's name against Dynamo Kyiv in a Champions League qualifier.
UEFA to trial safe standing in competition matches in England, Germany, France
Safe-standing areas will be allowed on a trial basis at European club games involving teams from England, Germany and France this season.
Roma coach Jose Mourinho gets tattoo celebrating historic trophy haul
Roma coach Jose Mourinho showed off a new tattoo on his arm picturing the three European trophies -- UCL, UEL and UECL -- he won during his career.