Arsenal recorded their first Premier League win under new manager Unai Emery after Issa Diop's own goal and Danny Welbeck's late strike saw West Ham fall to their third straight defeat.
The defensively frail Gunners came from behind to lead in fortuitous fashion as Alexandre Lacazette's volley across the area deflected in off Diop.
Hector Bellerin then picked out an unmarked Welbeck in added time and the substitute turned to lift his effort past Lukasz Fabianski.
West Ham captain Marko Arnautovic put the visitors in front on 25 minutes, exchanging passes with the impressive Felipe Anderson before slotting low past Petr Cech.
Nacho Monreal equalised five minutes later, firing into an unguarded net after Bellerin's cross deflected into the defender's path off Alex Iwobi.
Both Arnautovic and Robert Snodgrass then shot straight at Cech as the Hammers missed several chances to take the lead again, with former Gunner Lucas Perez also slicing wide late on in search of an equaliser.