The home side made a lively start to the match, with Carlos Tevez having two efforts at goal inside the opening 10 minutes.
Sergio Aguero almost broke the deadlock with a half-volley from deep inside the penalty area, but his strike was blocked by the post.
Having had few chances in the first half, West Ham came out more aggressive for the second period, with Matt Jarvis sending two dangerous-looking crosses into the home side's penalty area.
Tevez also looked to create chances for City, feeding the ball in for Nasri, who was unmarked, but the Frenchman was unable to reach it for a simple tap-in from six yards out.
James Collins had a good chance to level for the Hammers 10 minutes from full time with a strike from the edge of the penalty area, but the hosts had plenty of bodies in the box to ensure that the effort was blocked.
Man City immediately pushed down the other end of the field, with Yaya Toure picking the ball up 20 yards out and smashing it into the top corner to double the lead.
Andy Carroll almost gave West Ham some late hope, but Joe Hart was able to collect the ball on the line. However, the on-loan striker was able to force in a consolation goal for the visitors deep into stoppage time.