The Gunners had only won one and drawn another in their past six Premier League games, to leave their hopes of Champions League qualification – having reached the last 17 tournaments – in real jeopardy.
There were more protests against long-serving manager Arsene Wenger – with some Gunners fans not taking their seats until the 13th minute. It has been 13 years since they last won the league.
But it did not distract the team too much, admittedly against opposition in even worse form than themselves.
Arsenal had the best of the first half, but it was after the break they took control of the game.
Hammers keeper Darren Randolph was unhappy with Ozil’s opener as he felt Sanchez was offside and blocking his view, but referee Martin Atkinson did not care for his appeals.
The two Gunners stars both linked up to set up Walcott’s second, and then Giroud scored the game’s outstanding goal to clinch the match. The French striker, who replaced Danny Welbeck, has scored more Premier League goals as a substitute than anyone else this season – five.
Arsenal should have had a penalty in injury time when Sam Byram brought down Nacho Monreal.
The Gunners had to play their third-choice keeper, Emiliano Martinez, after injuries to Petr Cech and David Ospina. But the 24-year-old, on his first Premier League appearance since 2014, only had to make two saves in the game.