The Premier League club have announced the 54-year-old former Everton, Manchester United and Sunderland manager as successor to Slaven Bilic, who was sacked on Monday.
Bilic had been expected to see out the season with the Hammers but he was dismissed by joint-chairmen David Sullivan and David Gold after the 4-1 home defeat against Liverpool on Saturday.
Sky Bet make Moyes odds-on at 1/2 to still be in charge at the London Stadium on the first day of next season. He's 6/4 to have departed by that point.
"Do I have a point to prove? Yes, I think I do," Moyes told the club's official website.
"I've managed five clubs since starting out nearly 20 years ago, starting at Preston and then going to Everton. My period at Manchester United is well documented and I then did something I have always wanted to do by experiencing management abroad, with Real Sociedad.
"It's only been the last job where I feel it wasn't a good move and I didn't enjoy the experience. So I'm hungry to make sure I get things right now.
"The focus here is purely between now and the end of the season. The first thing is to win the next game and build from there, and I'm sure we will be in a much stronger position before long."
Sullivan told the club website: "I would like to welcome David to West Ham United.
"This is a unique position for David Gold and myself - it is the first time in almost eight years at West Ham United 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."
Moyes will be without Jose Fonte until the new year after the defender underwent ankle surgery on Monday.
The Portugal international, who suffered the injury against Crystal Palace the weekend before last, is expected to be out for two to three months.
"Now I've had the surgery, I will have to wear a cast for two weeks, then a boot for two weeks and finally a brace for two weeks, so that's six weeks. Then after that it's getting back my fitness levels," Fonte told the club website.
"I'm not scared of working hard, so I'll put the hard work in. We have great physios and great doctors at the club, so we'll be working hard together to be back stronger and fresher."