Roland Lamah had the Premier League outfit's first effort of the game by launching a curling shot towards goal from the edge of the box, but the ball just drifted wide of the post.
Jonjo Shelvey created a good chance in the first half as he got forward to unleash a shot on target, but his effort could not muster enough power and the ball flew straight into St Gallen goalkeeper Marcel Herzog.
The hosts wasted a great opportunity after the break as Swansea lost the ball in midfield, allowing Roberto Rodriguez to get in behind the defence, but his effort was lashed straight at the goalkeeper.
Swansea had their hearts in their mouths in the 70th minute as St Gallen had the ball in the back of the net, but it was disallowed following an apparent push on Neil Taylor.
The visitors then had substitute Jose Canas to thank as he was able to block a bullet header on the line, as Swansea found themselves on the ropes going into the last 15 minutes of the game.
The home side eventually took the lead through Marco Mathys in the 80th minute, when he converted an easy tap-in having been left free to roam in the Swansea box.
The loss did not matter, however, as Valencia were able to hold Kuban Krasnodar to a 1-1 draw, allowing the Welsh side to progress into the next round.