Defender Rio Ferdinand struck the winner three minutes from time, yet another one of the late goals which have been a feature of Ferguson's 26-year reign at the club.
Ferguson, in his 1,499th match at the helm, received a rapturous reception from the fans and a Guard of Honour from the players of both teams as he walked on to the pitch as heavy rain fell at Old Trafford.
Champions United started brightly and Javier Hernandez scooped a shot on to the underside of the crossbar after five minutes.
The home side dominated possession and they opened the scoring after 39 minutes when Mexican Hernandez reacted sharply to lash a loose ball low into the net from six metres.
Swansea briefly silenced the crowd when striker Michu equalised four minutes after halftime, getting in front of Phil Jones to steer a cross firmly past David de Gea for his 18th goal of the season.
Paul Scholes, making his 717th and final appearance for United, was substituted after 66 minutes and left the field in typically modest fashion to more warm applause.
Ryan Giggs, who has played in each of Ferguson's 13 title-winning teams, came on as a late replacement and although Swansea threatened to grab a winner it was United who found one.
A right-wing corner fell kindly to Ferdinand at the far post and the England defender gleefully lashed the ball into the net from six metres.
United are 13 points ahead of second-placed Manchester City with one match left in the season, away at West Bromwich Albion next Sunday.