The 54-year-old, whose Sunderland side were relegated from the Premier League last season, succeeds Slaven Bilic, who was sacked on Monday with West Ham 18th in the table.
Moyes, who has also managed Preston, Everton, Manchester United and Real Sociedad, becomes the 16th manager in the Hammers’ history and is expected to immediately take training with the club’s players that are not on international duty.
“I’m really looking forward to meeting the supporters, being in the stadium with them and seeing them get right behind the team, and my team also,” he said.
“We need everybody with us. It’s a big job we have in hand now but, with everybody together, I’m sure we can get the right results between now and the end of the season.”
Joint-Chairman David Sullivan said: “This is a unique position for David Gold and myself. It is the first time in almost eight years at West Ham that we have appointed a new manager during the season.
“We need somebody with experience, knowledge of the Premier League and the players in it, and we believe David is the right man to turn things around and get the best out of the players at the Club. He is highly regarded and respected within the game, and will bring fresh ideas, organisation and enthusiasm.
“He proved with Everton that he has great qualities and we feel that West Ham United is a Club that will give David the platform to display those qualities again.”