The 30-year-old spent last season on loan at Italian side Torino after Pep Guardiola took over as City boss last summer, and Hart was told once again that he was not in the Spaniard’s plans.
The Hammers are believed to be paying a loan fee of around £4.5 million ($5.9 million, 5.1 million euros) and the deal does not include a buy-back option at the end of the 2017/18 season.
City have agreed to contribute towards wages for Hart, who has been capped 71 times by his country.
“It’s important for me to play football and to get the opportunity to come here and play is absolutely awesome,” he told West Ham’s TV channel.
“To be playing in the Premier League for a big club like West Ham, I’m really looking forward to the season.
“We’ve moved into London Stadium and we’ve got Slaven (Bilic) in charge who I’ve spoken to and I’ve always enjoyed as a manager. He obviously did a good job with Croatia and he’s doing a good job here, so to get the opportunity to come here, it wasn’t really a hard decision.”
The former Shrewsbury Town player, whose current City contract doesn’t expire until 2019, is now expected to join his new team-mates on the club’s pre-season tour of Austria.
Download our app and read this and other great stories on the move. Available for Android and iOS.