The club, which is owned by the American Glazer family and listed on the New York Stock Exchange, did not immediately announce a successor.
The early bookmakers' favorites for the job are David Moyes, whose contract at Everton expires at the end of the season, and Real Madrid manager Jose Mourinho, the former Chelsea boss who craves a return to England.
Since taking charge at Old Trafford in 1986, Ferguson has won a total of 38 trophies, including 13 Premier League championships, two Champions League titles and five FA Cups.
"It was important to me to leave an organization in the strongest possible shape and I believe I have done so," Ferguson said. "The quality of this league winning squad, and the balance of ages within it, bodes well for continued success at the highest level whilst the structure of the youth setup will ensure that the long-term future of the club remains a bright one."
Ferguson reversed a previous plan to retire at the end of the 2001-02 season.
After United secured its latest Premier League title two weeks ago extending the club's record English championship haul to 20 Ferguson declared that he had no retirement thoughts.
But now he has just two more league matches left in charge of the club he has turned into one of the world's biggest sports powers.
Ferguson has previously said only health problems would force him to relinquish the job, and it emerged over the weekend that he requires hip surgery. However, the retirement statement did not mention health issues.
Ferguson will continue to loom large at United as he will remain as a club director and ambassador.
"His contributions to Manchester United over the last 26 years have been extraordinary and, like all United fans, I want him to be a part of its future," joint chairman Avie Glazer said.
Talk of Ferguson leaving first surfaced following the club's golf day on Tuesday. When the official announcement came it prompted an outpouring of tributes from inside and outside the game.
FIFA President Sepp Blatter said on Twitter that Ferguson's "achievements in the game place him without doubt as one of the 'greats'."
Former United striker Michael Owen said Ferguson's record "will surely never be eclipsed."
"What an act to follow," Owen tweeted.
The announcement even grabbed the British media spotlight from the buildup to the State Opening of Parliament, where Queen Elizabeth II, who knighted Ferguson in 1999, was setting out the government's planned legislation.
Ferguson has played a high-profile role campaigning for the Labour Party.
"Proud man. Great manager. Staunch Labour Party supporter," Labour Party leader Ed Miliband tweeted. "Sir Alex Ferguson will never be forgotten."
Tributes crossed the political divide, with Sports Minister Hugh Robertson, a member of the Conservative Party, praising Ferguson for his "enthusiasm for our national game."
Ferguson has defined the modern era of success at United, resuscitating the fortunes of a club that was floundering when he arrived more than a quarter of a century ago, having won a European title at modest Aberdeen in Scotland.
While it took time for Ferguson to impose his leadership at Old Trafford, directors showed a degree of patience rarely afforded to current managers.
Ferguson eventually produced his first trophy in 1990 the FA Cup and in 1993 the club won its first topflight title since 1967.
Since then, he has turned United into a European power and one of the world's wealthiest sports clubs. In addition to Champions League titles in 1999 and 2008, United has also won four League Cups and the 2008 FIFA Club World Cup.
"In my early years, the backing of the board, and Sir Bobby Charlton in particular, gave me the confidence and time to build a football club, rather than just a football team," Ferguson said. "Over the past decade, the Glazer family have provided me with the platform to manage Manchester United to the best of my ability."
Before United was listed on the NYSE last year, the club warned that "any successor to our current manager may not be as successful as our current manager."
"A downturn in the performance of our first team could adversely affect our ability to attract and retain coaches and players," United said in July.