Ivan Sproule's low effort into the bottom left-hand corner of the net proved the difference between the sides as Linfield moved up to third place.
The former Northern Ireland forward scored 50 seconds into the second half.
Kris Lowe had chances for the Swifts in both halves, while the Blues wasted several opportunities before the break.
Chris Hegarty, Aaron Burns, Stephen Lowry, Sproule and Jimmy Callacher all went close while Gary Liggett had a late penalty appeal turned down.
Early in the game, Lowe fluffed his shot in front of goal, and was then denied by Jonny Tuffey.
Hegarty squandered a good chance, then Burns saw his weak effort saved by Andy Coleman when he was clean through on goal.
Lowry fired straight at the keeper, Sproule was wide with a back-post header and Callacher was off-target with a looping, curling attempt on goal.
Sproule eventually broke the deadlock to give the Blues a victory they just about deserved.