Arsenal warmed up for their crucial Champions League second-leg tie at Monaco on Tuesday with a 10th successive win over West Ham.
The Gunners dominated the first half before Olivier Giroud smashed in an angled drive just before half-time.
Kevin Nolan and Matt Jarvis came close to scoring for the Hammers.
But late strikes from Aaron Ramsey and Mathieu Flamini earned a win which puts Arsenal a point behind second-placed Manchester City.
City’s 1-0 defeat by Burnley came after a convincing performance from Arsene Wenger’s side, who will be aiming to overturn a 3-1 deficit in France next week.
An identical scoreline would see them progress but as unlikely as that might be, the Frenchman will be pleased his side came through the game unscathed and finally found their range after wasting a number of chances.
Until the strikes from Ramsey and Flamini, West Ham looked like they might build up a period of sustained pressure, but the introduction of Santi Cazorla helped earn Arsenal a seventh win in their last eight games.
Conjuring up a number of flowing moves from the start, the Gunners should have gone into the break more than one goal ahead. They only held a slender lead thanks to several saves from West Ham goalkeeper Adrian.
The opportunities arrived as early as the fifth minute when the Gunners had a strong penalty appeal waved away by referee Chris Foy after James Collins bundled over Arsenal forward Theo Walcott.
Walcott, in for injured winger Alex Oxlade-Chamberlain, showed some rustiness when presented with further opportunities in what was only his third Premier League start of the season.
Other Arsenal players, such as Alexis Sanchez and Ramsey, found Adrian an unbreachable force.
The home crowd began to grow frustrated but they went into the break lifted by Giroud’s goal as the French striker finished another neat interchange by crashing his shot in off the far post. It was his sixth goal in seven games.
With Diafro Sakho a lone threat up front, Hammers boss Sam Allardyce screamed at his players to get further forward in the second half.
It seemed to have an effect as West Ham grew in influence and Jarvis went close, but he could not keep his shot down from a corner.
Giroud played his part in the second goal as he set up Ramsey following a throw-in, with Flamini adding the gloss from close-range with his first touch.