Linked with a return to his former club Everton recently, Moyes has committed his future to the Hammers, who finished sixth under his leadership in last season's Premier League.
That secured a UEFA Europa League place and West Ham's 65-point haul was its best in a Premier League campaign.
Moyes, 58, has also previously led Manchester United, Real Sociedad, Sunderland and Preston North End, and this is his second spell at West Ham.
"I am delighted to have committed my future to West Ham United," Moyes said.
"This is where I want to be and I'm happy. I'm excited to be given this opportunity to build on what we all have already achieved here. The owners and I are fully aligned with how we want to keep developing and improving the football club.
"The board and everyone at the club have been fantastic to work with, giving me great support and I feel that we are all united in what we want to achieve in the coming years and how we might be able to achieve those things."
Moyes pointed to "tremendous progress" during his second stint at the Hammers, having taken charge in late December 2019 when there was plenty of scepticism about his appointment, many feeling his best days as a manager were behind him.
The Scot has shown his doubters to have underestimated his ability to turn around the team's fortunes.
"The players really have been superb but the challenge is for our standards to continue developing. We must keep pushing boundaries for consistent improvement as we all aim to continue the growing of the club," Moyes said.
West Ham joint-chairmen David Sullivan and David Gold issued a joint statement on the club's official website supporting Moyes's commitment, describing it as "fantastic news" that would ensure "great stability going forward".
Sullivan and Gold said: "The experience of the past 12 months has created a fantastic unity throughout the club and we are very excited about what the future holds for our supporters."