The Gunners had slumped to successive defeats against Manchester City and Chelsea to leave them facing an uphill battle to regain a place in the top four.
Wenger knew there was no more margin for error, but must have feared another night of frustration after falling behind in the rearranged Boxing Day fixture to a fine strike from Jack Collison.
However, Lukas Podolski crashed in a 25-yard effort to equalise before the break.
Olivier Giroud then scored his first goal in six games to put the hosts in front just after the restart, before German forward Podolski tore the Irons apart, charging down the left to set up Santi Cazorla, Theo Walcott and Giroud again as Arsenal romped out of sight before the hour.
West Ham had to play the closing stages with 10 men after what looked a serious injury to substitute Daniel Potts, who was carried off on a stretcher following a serious head injury and kept in hospital overnight for observation.
"We got a good response," said Wenger. "I could not predict that we would score five goals, but what was vital for us was to equalise before half-time and then see if West Ham could maintain their control of us.
"In the second half from the start on we created chance after chance and played at a very high pace. From there on it was great movement, great quality in our final balls and in our combination play.
"Until Potts got injured of course, after that it was the end of the game because we played 11 against 10 and it was [already] 5-1."