A draw at a foggy AFG Arena would have been enough for Michael Laudrup's men to secure their own safe passage through to the knockout stages.
Instead, they went down to a deserved 80th-minute goal scored by midfielder Marco Mathys - but Kuban Krasnodar could only draw 1-1 at Valencia in the other game in the group, meaning the Russians did not unseat the Swans from second spot.
Swansea will learn their round-of-32 opponents when the draw is made in Nyon on Monday. They will face either a group winner, or one of the four best third-placed Champions League sides - either Napoli, Benfica, Shakhtar Donetsk or Basel.
Laudrup made six changes to his side in north-east Switzerland. Wilfried Bony shook off a hamstring strain in time to replace Michu, while Jordi Amat, Neil Taylor, Wayne Routledge, Alejandro Pozuelo and Roland Lamah were also recalled following Monday's 1-1 Premier League draw with Hull.
Swansea's preparations for this fixture had been far from ideal after fog and technical issues ensured their journey on Wednesday took over 12 hours. Some players were also awoken by a shallow earth tremor in the early hours of the morning.
But they managed to take an early control of the match, with Lamah curling just wide and later firing narrowly off-target with a low shot.
Full-back Dwight Tiendalli's decision to allow Ermir Lenjani the freedom of the left-hand side of the field was particularly poor in the first half, and roused Laudrup from the bench after the midfielder had flashed a shot just wide.
However, their hosts were much improved after the break and Roberto Rodriguez was twice denied by Gerhard Tremmel after some poor Swansea defending.
Mathys' pass put Rodriguez in on goal but Tremmel saved his low effort, and followed that with another good stop from the same player after Tiendalli had played three St Gallen players onside.
Swansea then lost Chico Flores with what appeared to be an ankle problem, and their discomfort continued when Wuthrich struck the post with a free-kick.
St Gallen thought they had gone in front on 72 minutes. The ball was swung over from the right and into the six-yard box where Sebastien Wuthrich and Taylor competed for it, only for the latter to put through his own net. However, the extra official behind the goal ruled that Wuthrich shoved Taylor and the referee disallowed the strike.
Jose Canas, on for Flores, then cleared a Mathys header off the line as the pressure increased.
However, with 10 minutes left, Wuthrich crossed from the left and sloppy defending allowed the unmarked Mathys to stab the ball home for the only goal of the game.
|FC St Gallen||Team Statistics||Swansea City|
|0||1st Half Goals||0|
|6||Shots on Target||2|
|5||Shots off Target||6|
|35.1||1st Half Poss.||64.9|
|25.8||2nd Half Poss.||74.2|