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.
- CNN to sue over Acosta's White House press pass?
- Tom Brady Responds To Dion Lewis’ Trashing Of The Patriots
- In Paris, Trump stood alone
- Fans Adding Danny DeVito to the Detective Pikachu Trailer
- 'It's just a recipe for destruction,' fire chief says of California wildfires
- Facebook goes down for users around the world
- Sinema pads narrow lead in tight Senate race
- Emmanuel Macron May Have Thrown Shade At Donald Trump Over Twitter Diplomacy
- Mahomes throws 2 TD passes as Chiefs beat Cardinals 26-14
- Forest fires in California, killing 31 people, 228 missing