Arsenal took the lead on 51 minutes when Nacho Monreal volleyed in Granit Xhaka's corner for his fifth PL goal of the season.
Marko Arnautovic levelled in the 64th minute when he sent Manuel Lanzini's clever pass past David Ospina with an angled strike.
Joe Hart denied Xhaka and then Danny Welbeck but Arsenal went ahead again when Aaron Ramsey's cross drifted over Declan Rice and past the West Ham goalkeeper with eight minutes remaining.
Lacazette made it 3-1, latching on to Pierre-Emerick Aubameyang's cutback. The Frenchman then struck again after fine approach play by Ramsey.
Arsenal, in sixth, move four points clear of Burnley. West Ham are 15th, six points above the relegation zone.
Arsenal: 29 Apr v Man Utd (A)
West Ham: 29 Apr v Man City (H)