The Reds beat nine-man Newcastle 2-1 to finish a brilliant season in second place.
Elsewhere, Tottenham beat Aston Villa 3-0 to finish sixth and claim a Europa League berth, while Norwich's relegation was officially confirmed following a 2-0 defeat at home to Arsenal, who finish fourth, behind Chelsea in third, who ended the campaign with a 2-1 win at relegated Cardiff.
Man United finish seventh after a 1-1 draw at Southampton.
City were rarely troubled by West Ham in the first half and took the lead on 39 minutes when goalkeeper Adrian lacked a strong enough hand to keep out Nasri's dipping 25-yard drive.
Manuel Pellegrini's side almost scored a second in stoppage-time when David Silva's shot deflected off Andy Carroll and struck the crossbar.
The second goal came four minutes after half-time when a corner deflected into Kompany's path and the defender finished from close range to ensure City secured the title in Pellegrini's first season as manager.
Liverpool came from behind to round off their excellent season with a 2-1 home win over Newcastle, who finished the match with nine men.
Liverpool fell behind in the 20th minute when Yoan Gouffran got down the left-hand side and his cross was shinned into his own net by defender Martin Skrtel.
Gouffran should have then made it 2-0 when he was sent clear, but his shot was well saved by Simon Mignolet before Liverpool striker Daniel Sturridge headed wide when picked out unmarked in the box.
Brendan Rodgers' side equalised on 63 minutes when Steven Gerrard's free-kick from the right was steered home by Daniel Agger at the far post.
Just two minutes later, Liverpool took the lead in almost identical fashion as Gerrard whipped in another free-kick from a similar position, but this time it was Sturridge at the back post to score from close range.
And, before the game could restart, Newcastle striker Shola Ameobi was sent off after being booked twice in quick succession by referee Phil Dowd for dissent.
Newcastle were reduced to nine men with three minutes to go when Paul Dummett was sent off just five minutes after coming on as a substitute following a collision with Luis Suarez.
Arsenal edged in front in stunning fashion on 53 minutes when Olivier Giroud crossed from the left to the far post where Aaron Ramsey volleyed first time beyond John Ruddy into the top corner.
Arsene Wenger's side added a second goal nine minutes later when Kieran Gibbs' cut-back bounced into the path of Carl Jenkinson and the full-back side-footed home his first Arsenal goal with the aid of a deflection.
Stoke were handed the advantage midway through the first half in fortunate fashion when Marko Arnautovic's pull-back was turned into his own net by Gareth McAuley, who was running back towards his own goal.
West Brom equalised on 56 minutes when Stephane Sessegnon, who hit the crossbar after just three minutes, swept home Craig Dawson's cross.
But Stoke clinched a fifth successive win at The Hawthorns with three minutes to go when Charlie Adam drove an angled left-footed effort from 25 yards beyond the dive of Ben Foster.
Tottenham took the lead on 14 minutes when the ball broke kindly into Paulinho's path and, after his initial shot was parried by Brad Guzan, the Brazil international scored from the rebound.
There was an element of fortune about Spurs' second goal on 35 minutes when Danny Rose's driven cross brushed Emmanuel Adebayor before deflecting past Guzan off Nathan Baker.
And three minutes later, Spurs made it 3-0 when Adebayor blasted home a penalty after Sandro's shot had struck Gabriel Agbonlahor on the arm.
Southampton went in front in the 28th minute when Rickie Lambert collected Steven Davis' pass to score, although United were unhappy after the England international's flailing elbow left Nemanja Vidic with a bloodied face.
United drew level nine minutes into the second half when record signing Juan Mata curled a 25-yard free-kick over the wall and into the top corner.
Cardiff forged in front on the quarter-hour mark when Craig Bellamy's 25-yard effort took a wicked deflection off Cesar Azpilicueta on its way past Mark Schwarzer.
Chelsea levelled on 72 minutes when substitute Andre Schurrle fired home the loose ball after Azpilicueta had first been denied by David Marshall and then the crossbar.
Just three minutes later, Chelsea were in front when Schurrle's header found an onside Fernando Torres and the Spain striker had a simple finish past Marshall.
Romelu Lukaku marked the final appearance of his loan spell at Everton with a goal as Roberto Martinez's men beat Hull City 2-0 at the KC Stadium.A well-worked goal put Everton ahead on nine minutes when Lukaku and Steven Naismith combined to play in James McCarthy and the midfielder's shot struck the hands of fit-again Hull keeper Allan McGregor on its way into the net.
Everton increased their lead in the opening minute of the second half via another fine move which ended with Leon Osman slipping a pass through to Lukaku, who curled his shot past McGregor.
Palace took the lead on 28 minutes when Gayle, who scored twice in Monday's thrilling 3-3 draw with Liverpool, diverted Joel Ward's shot beyond David Stockdale.
Fulham levelled in the 61st minute when young striker Cauley Woodrow cut inside before curling a shot past Wayne Hennessey for his first goal for the club.
But Palace were back in front with six minutes to go when the in-form Gayle whipped a 25-yard free-kick around the wall and beyond Stockdale.
Felix Magath's side did provide their fans with a final flourish as, in the third minute of added time, David cut inside and thumped a shot in off the bar.
Garry Monk marked his first game since being named Swansea's permanent manager with a 3-1 win over Sunderland at the Stadium of Light.Swansea went ahead after just seven minutes when Wayne Routledge's superb slide-rule pass played in Nathan Dyer and he clipped his shot over Vito Mannone.
The visitors doubled their lead on 14 minutes when Marvin Emnes turned sharply on the edge of the box from Wilfried Bony's pass and lashed a shot past Mannone.
Sunderland pulled a goal back five minutes into the second half when on-loan striker Fabio Borini marked his final appearance by heading home a corner.
But Swansea restored their two-goal cushion four minutes later when Emnes' cross deflected out to Bony and his low shot went in via the post.