Uefa found Nasri guilty of breaching World Anti-Doping Code and Uefa's anti-doping regulations when he was pictured receiving an intravenous drip at a clinic in Los Angeles.
He will be able to play from 1 January, 2019 and would be reunited with one of his bosses at City, Manuel Pellegrini.
Nasri could add some inventive spark to West Ham's midfield, but his fitness levels could be an issue given the amount of time he has gone without playing professional football.
The Hammers are now missing Jack Wilshere, who signed from Arsenal in the summer but fell victim to yet another injury, and Andriy Yarmolenko, who tore his achilles tendon three weeks ago, ruling himself out for the remainder of the season.
But the former France global has encountered a troubled career since, having been banned for 18 months by UEFA for doping.
They also rank 13th for chances created across the division as well as 11th for goals scored which perhaps highlights why Pellegrini is interested in recruiting an attack-minded midfield player of Nasri's ilk.
Nasri, who made his name in England with West Ham's London rivals Arsenal after joining from Marseille, left Turkish side Antalya in January after a disappointing six-month spell following his arrival from City.
- Attorneys For Broward Elections Office And Rick Scott Reach Compromise On Security
- Kate Upton welcomes her first child
- Emmanuel Macron May Have Thrown Shade At Donald Trump Over Twitter Diplomacy
- In Paris, Trump stood alone
- Deepika Padukone and Ranveer Singh to wear Sabyasachi for their wedding
- Fans Adding Danny DeVito to the Detective Pikachu Trailer
- UN Nuclear watchdog says Iran abiding by 2015 deal limits
- Amazon Will Split HQ2 Between NY, Northern Virginia
- California Wildfires From Space Show Their Massive Scope
- Sinema pads narrow lead in tight Senate race