The Welsh side knew that a point would secure their qualification for the knockout stages from Group A but instead a second-half Marco Mathys goal allowed the already-eliminated hosts to bow out on a high.
Nevertheless, the defeat did not prevent the Swans from advancing as Kuban Krasnodar failed to get the victory they required away to Valencia in Spain to stand a chance of grabbing second place.
Paraguayan Lorenzo Melgarejo scored to earn the Russians a 1-1 draw after Paco Alcacer put group winners Valencia ahead at the Mestalla, but Kuban bowed out.
Swansea manager Michael Laudrup was relieved at seeing his men go through to Monday's draw for the first knockout round after they failed to build on a promising start in Group A.
The English Premier League club won their opening two matches, but took just two points from their following four games and never got a grip of Thursday's encounter, much of which was played in thick fog.
Perhaps still feeling the effects of serious travel delays on Wednesday which forced them to cancel their eve-of-game training session at the AFG Arena, they spent much of the game on the back foot.
After a quiet first half, St. Gallen grew as a threat after the restart, but visiting goalkeeper Gerhard Tremmel made two good saves to deny Roberto Rodriguez before Sebastien Wuethrich hit the woodwork from a free-kick.
St. Gallen then had a goal disallowed when Neil Taylor turned a cross into his own net but Wuethrich was penalised for a foul on the Swansea captain.
However, Mathys turned in a low Wuethrich cross following a quick free-kick to put the Swiss Super League side in front with ten minutes left.
Pablo Hernandez fired wide with Swansea's best chance late on but they limp through and will play European football after Christmas for the first time in their history.
"We're there, that's the most important thing," Laudrup said.
"I'm never happy when we lose but we went through and I think in a couple of days after the draw we will feel differently."
Soldado's hat-trick leads Spurs past Anzhi, Wigan crash out
Tottenham Hotspur, who had already qualified before hosting Anzhi Makhachkala at White Hart Lane, made it six wins from six in Group K by beating the Russians 4-1.
Spanish striker Roberto Soldado, whose form since signing for Spurs in the summer has been the subject of criticism, scored a hat-trick, including one penalty, while Lewis Holtby also netted with a classy finish as Andre Villas-Boas' side ran out comfortable winners.
"It was a good standard of play. We kept the ball well, created lots of chances and it was pleasing for the fans," Villas-Boas said.
"We are back on track and we go into a big game now (against Liverpool in the Premier League) with momentum."
Last season's FA Cup winners Wigan Athletic were eliminated from Group D, finishing bottom of the section after a 2-1 defeat away to Slovenian champions Maribor.
In new manager Uwe Rosler's first game in charge, Wigan had to win to stand a chance of going through and a Jordi Gomez penalty put them in front.
However, Chris McCann was sent off moments later for a second booking after handling in the box and Dejan Mezga tapped in to equalise after his penalty had been saved.
Zeljko Filipovic then put Maribor in front in the second half, and they held on to win despite having Ales Mertelj sent off late on.
Maribor qualified for the last 32 courtesy of their better head-to-head record against Belgian side Zulte Waregem, who lost 2-0 to section winners Rubin Kazan.
Former European champions PSV Eindhoven needed just a point to go through from Group B but were eliminated after losing 1-0 at home to Chornomorets Odessa, a Franck Dja Djedje goal taking the Ukrainians through instead.
Their compatriots Dynamo Kiev beat Rapid Vienna 3-1 to go through from Group G, while Israel's Maccabi Tel Aviv and Czech side Slovan Liberec also clinched their berths in the last 32.
Teams through to Monday's draw for the first knockout round of the Europa League
Valencia (ESP), Swansea City (ENG), Ludogorets Razgrad (BUL), Chornomorets Odessa (UKR), Salzburg (AUT), Esbjerg fB (DEN), Rubin Kazan (RUS), Maribor (SLO), Fiorentina (ITA), Dnipro Dnipropetrovsk (UKR), Eintracht Frankfurt (GER), Maccabi Tel Aviv (ISR), RC Genk (BEL), Dynamo Kiev (UKR), Sevilla (ESP), Slovan Liberec (CZE), Lyon (FRA), Real Betis (ESP), Trabzonspor (TUR), Lazio (ITA), Tottenham Hotspur (ENG), Anzhi Makhachkala (RUS), AZ Alkmaar (NED), PAOK (GRE)
Qualified as third-place finishers in Champions League group stage
Shakhtar Donetsk (UKR), Juventus (ITA), Benfica (POR), Viktoria Pilsen (CZE), FC Basel (SUI), Napoli (ITA), FC Porto (POR), Ajax (NED)
*Group winners and four best third-place finishers in Champions League cannot play each other. Teams from same country cannot be drawn together.