The Manchester United manager entered the Old Trafford pitch against the backdrop of 'The Impossible Dream' and a cacophony of noise, as players and staff from both teams formed a guard of honour for the outgoing boss.
The home side seemed determined to give Ferguson a memorable sending off and within the first five minutes Robin van Persie threaded a ball into Javier Hernandez, who rattled the crossbar with a left foot strike from a tight angle.
Van Persie once again teed up his fellow strike partner on the half-hour mark, but the Mexican striker could only fire over the bar from 18 yards.
Then with half time approaching, Manchester United opened the scoring. Van Persie swung a free kick into the box that Swansea failed to deal with and Hernandez tucked the loose ball underneath the onrushing Gerhard Tremmel.
Swansea emerged from the dressing rooms with a renewed energy at the start of the second half, and Michu - who returned to the starting line up for the game - threatened to ruin the Old Trafford party with a neat volley with the outside of his left foot.
The visitors continued to cause Manchester United problems and Nathan Dyer fed Pablo Hernandez, whose drilled effort was tipped behind by David de Gea. From the resulting corner, Phil Jones and Patrice Evra blocked magnificently after the ball fell to Chico Flores in the area.
A minute later Javier Hernandez came inches away from connecting with Danny Welbeck's low cross.
Paul Scholes, making his last appearance for the club, left the field after 65 minutes to a standing ovation from both sets of fans.
Brazilian midfielder Anderson, who replaced Scholes, came close to putting the home side ahead, but his volley flew just wide of Tremmel's post.
Despite Swansea having good spells in the second half, Manchester United snatched a late winner.
Van Persie's corner fell to the unmarked Ferdinand, who lashed the ball home much to the delight of his 71-year-old manager and the jubilant home fans inside the stadium.