The 50-year-old will take charge at Old Trafford on July 1 after completing the season with Everton.
Moyes has the backing of Sir Alex Ferguson, who will retire at the end of the season, and his first official game will be the Community Shield against either Manchester City or Wigan at Wembley on August 11.
Moyes, who has spent 11 years with Everton, said: "It's a great honour to be asked to be the next manager of Manchester United.
"I am delighted that Sir Alex saw fit to recommend me for the job. I have great respect for everything he has done and for the football club.
"I know how hard it will be to follow the best manager ever, but the opportunity to manage Manchester United isn't something that comes around very often and I'm really looking forward to taking up the post next season.
"I have had a terrific job at Everton, with a tremendous chairman and board of directors and a great set of players.
"Between now and the end of the season, I will do everything in my power to make sure we finish as high as possible in the table.
"Everton's fantastic fans have played a big part in making my years at Goodison so enjoyable and I thank them wholeheartedly for the support they have given me and the players.
"Everton will be close to me for the rest of my life."
Ferguson, who is stepping down as United manager after a near 27-year stint, said: "When we discussed the candidates that we felt had the right attributes, we unanimously agreed on David Moyes. David is a man of great integrity with a strong work ethic.
"I've admired his work for a long time and approached him as far back as 1998 to discuss the position of assistant manager here.
"He was a young man then at the start of his career and has since gone on to do a magnificent job at Everton.
"There is no question he has all the qualities we expect of a manager at this club."
Served wonderfully well
Everton chairman Bill Kenwright paid tribute to Moyes earlier on Thursday after it emerged that he would be leaving Goodison Park after 11 years at the helm.
He said: "I think, at the end of the day, David's contract is up in six weeks' time and he has a right to make his own decisions. He's served this club wonderfully well."
Moyes quickly emerged as the favourite to become United's boss after Sir Alex Ferguson announced he would be retiring, and received widespread support.
Former Manchester United striker Michael Owen revealed he would choose the Everton boss, saying: "What an act to follow. I guess only Mourinho would have the confidence to strut through the door. If it were me, I'd go for Moyes."
Former United keeper Peter Schmeichel also gave his backing to Moyes, saying: "When we talk about Moyes, he has been a decade at Everton and done a fantastic job on limited funds.
"Is he cut from the same cloth? I don't know. Don't forget there will be major changes with David Gill stepping down - the club is really changing in the summer, the more stability they can add the better.
"David Moyes, he sounds like a good solution."
United chief executive David Gill had previously outlined the qualities needed to succeed Ferguson as manager, saying: "The qualities are the ones that have been inherent at Manchester United for many years.
"Our two most successful eras were with managers who got involved with all aspects of the club, from the youth team to the first team, to get that degree of loyalty and understanding of the football club.
"Clearly he has to have the requisite football experience, both in terms of domestic and European experience. It is a small pool."
Everton, meanwhile, must start their search for a successor to Moyes, and Mark Hughes has refused to rule himself out of the running for the job.
"I think when one manager leaves there are opportunities for other managers who are currently out of work, which includes myself," Hughes told Sky Sports News.
"It's a great club; it's a club that I had the fortune to play for and really enjoyed my time there."