Arsenal overtook opponents West Ham and moved into fourth place in the Premier League with victory in an eventful match at Emirates Stadium.
Gabriel Martinelli netted the opener early in the second half before substitute Emile Smith Rowe confirmed victory for the Gunners late on.
Arsenal captain Alexandre Lacazette also had a penalty saved by goalkeeper Lukasz Fabianski in the second half.
West Ham's Vladimir Coufal was sent off for a second booking in conceding the penalty as he was judged to have fouled Lacazette in the box.
Coufal had been booked in the first half when his flailing arm caught defender Kieran Tierney in the face, inciting protest from the Arsenal players.