Arsene Wenger's side are in danger of failing to reach Europe's elite club competition for the first time in 17 years after a miserable run saw them surrender fourth place to Everton.
The Gunners needed a victory over their London rivals to climb back into fourth, but their European bid looked in dire straits when Matthew Jarvis struck for the visitors late in the first half at the Emirates Stadium.
That shock revitalised a previously lethargic Arsenal and German forward Lukas Podolski equalised minutes later before France striker Olivier Giroud put them ahead soon after the interval.
Podolski's second in the closing stages sealed Arsenal's first victory in their last five league games and lifted the north Londoners one point clear of Everton, although Roberto Martinez's men are still in pole position as they will reclaim fourth place if they draw or win at home to Crystal Palace on Wednesday.
"We were under absolute pressure to win the game and after giving a lot on Saturday it was difficult," Wenger said.
"I was satisfied with the mental response of the team. We showed maturity not to panic when we went 1-0 down.
"The vital thing was to come back to 1-1 before half time. It was a hard-fought and very enjoyable win."
Hammers boss Sam Allardyce added: "We worked really hard to get 1-0 up, but if you gift them two goals it's difficult to get a result. The defending for the second goal was pathetic."
Wenger had made five changes from the team that beat Wigan on penalties in Saturday's FA Cup semi-final, with Swedish midfielder Kim Kallstrom making his first start and Laurent Koscielny returning from injury.
But the Gunners spluttered in the early stages and when they did get behind the West Ham rearguard thanks to Santi Cazorla's defence-splitting pass, Giroud, back in the starting line-up after being left out of the semi-final, could only flick a tame effort straight at Adrian.
It seemed Arsenal might pay the price for that miss when Allardyce's team took the lead in the 40th minute.
Antonio Nocerino made a powerful burst from midfield and held off Kallstrom to drive in a low shot that Wojciech Szczesny blocked at his near-post.
Nocerino was first to the rebound and poked it towards Jarvis, who bravely ignored Koscielny's desperate head-high attempt to clear and nodded home from close-range.
To their credit, the setback sparked Arsenal into life at last and Kallstrom forced Adrian to save at his near-post before the Gunners equalised in the 44th minute.
West Ham were the architects of their own downfall as a poor clearance from Stewart Downing from his own team's throw-in fell to Cazorla, who slipped a lovely pass to Podolski and the German showed great awareness to work just enough space to fire a superb low strike past Adrian for his ninth goal of the season.
Wenger's men now had the platform to play with more freedom and they went ahead 10 minutes after the break thanks to a moment of inspiration from Giroud.
When Thomas Vermaelen lofted a high ball into the penalty area, Giroud was buffeted by Winston Reid and Andy Carroll, but he was strong enough to hold off his assailants and control the dropping ball expertly before lashing home from close-range.
Giroud celebrated his 20th goal of the season by paying tribute to the 96 Liverpool fans who died in the Hillsborough disaster as he marked the 25th anniversary of the tragedy by kissing his black armband and pointing to the sky.
Podolski sealed the Gunners' eighth successive victory over West Ham in emphatic fashion, driving home a lethal finish after Giroud and substitute Aaron Ramsey combined to open up the visitors' defence in the 78th minute.