The hosts enjoyed the better of the opening 45 minutes but fell behind shortly before the break when Winston Reid fouled Santi Cazorla in the box and the Spaniard dispatched the subsequent penalty.
Danny Welbeck doubled Arsenal’s advantage a couple of minutes later as he tapped in Alex Oxlade-Chamberlain’s cross from a few yards out.
The Hammers halved the deficit early in the second half as Cheikhou Kouyate headed in his first goal for the club.
But despite piling on the pressure they could not grab an equaliser as Enner Valencia headed over the bar in injury time and the Gunners held on for all three points.
The win is the perfect end to the year for Arsenal, who largely coped well with the Hammers’ physical presence and also looked threatening throughout on the break during an entertaining encounter.
Both sides made a number of changes from their Boxing Day outings 48 hours earlier, with Sam Allardyce preferring Diafra Sakho ahead of Valencia and Arsenal replacing the suspended Olivier Giroud with Oxlade-Chamberlain and handing a first start since January 2013 to Francis Coquelin.
Former Gunner Alex Song thought he had broken the deadlock early on when he drove in a brilliant volley from 25 yards, only for it to be ruled out for offside.
It looked to be a harsh decision as no West Ham player touched the ball on its way through a crowd, but the linesman ruled the players in an offside position in front of Wojciech Szczesny were interfering with play.
The Hammers were also aggrieved a few minutes later as Sakho went down in the box under a challenge from Mathieu Debuchy and the penalty appeals were waved away.
At the other end, a crucial block from Joey O’Brien prevented Alexis Sanchez closing in on goal before the Chilean miscued a header from Cazorla’s free-kick.
Andy Carroll served warning of his threat as he easily outmuscled Debuchy as they competed for a high ball, only to then drag his volley well off target.
The Hammers continued to look dangerous from set pieces and spurned a decent chance to take the lead when James Tomkins wastefully volleyed over the bar from an excellent position.
The miss would prove costly as the Gunners then stunned the home side with two goals in as many minutes just before half-time.
There was a hint of fortune about the first as the ball ricocheted through kindly for Cazorla, but he was then clearly fouled by Reid inside the box and made no mistake from the penalty spot.
That was Arsenal’s first shot on target and they made it 2-0 with their second as Oxlade-Chamberlain combined well with Debuchy down the right and then crossed for Welbeck to tap in.
Stewart Downing went close to halving the deficit as he dragged a shot wide from just inside the box before Sanchez saw an effort deflected just wide at the other end.
While the home side would have been disappointed to be 2-0 down at the break, it didn’t take them long to get on the scoresheet in the second half.
After Per Mertesacker did well to beat Carroll to a header, the ball was lofted back into the box by Tomkins and Kouyate easily rose above Debuchy to head home.
The goal was just what the Hammers needed and Sakho was inches away from turning in Kouyate’s cross to equalise moments later.
With the Arsenal box under regular bombardment, the visitors’ best moments came on the break, with Adrian pulling off excellent saves to deny both Oxlade-Chamberlain and Sanchez.
Welbeck, though, should have put the game to bed when a misplaced pass from Downing gave the England striker a clear run at goal, but he shot over the bar.
The Hammers piled on the pressure in the closing stages, with Adrian even going forward for a few set pieces, but Valencia headed their last chance over the bar in the dying stages.
Soccer Special – Phil Thompson’s verdict
“For the neutral this was absolutely stunning, it was a magnificent game. It was a second game in three days, with both sides giving everything. I didn’t want the game to end, it was that good. Szczesny deserves great compliments because he has made a big decision that anything in the air he is going to come and get and control the air in the penalty area. He had to be precise.”
West Ham: Adrian (7), O’Brien (5), Reid (5), Tomkins (5), Amalfitano (6), Downing (5),Kouyate (7), Song (5), Carroll (6), Sakho (6).
Subs: Demel (5), Nolan (5), Valencia (6).
Arsenal: Szczesny (7), Debuchy (5), Mertesacker (6), Koscielny (6), Monreal (5), Coquelin (6), Flamini (6), Cazorla (7), Oxlade-Chamberlain (7), Welbeck (7), Sanchez (7).
Subs: Chambers (5), Gibbs (5).
Man of the match: Alex Oxlade-Chamberlain.