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.
- Fans Adding Danny DeVito to the Detective Pikachu Trailer
- 'Public Hanging'Remark Provokes Outrage, Draws New Attention to Mississippi Senate Runoff
- Tom Brady Responds To Dion Lewis’ Trashing Of The Patriots
- Mostly Non-Impactful Snow To Start Tuesday
- Ind vs WI 3rd T20: Chahal sees off Shai Hope
- Trump cancels memorial visit to U.S. cemetery in France due to rain
- Mahomes throws 2 TD passes as Chiefs beat Cardinals 26-14
- Sinema pads narrow lead in tight Senate race
- Kate Upton welcomes her first child
- UFO investigation after pilots report fast-moving lights over Ireland