Goals from both centre-halves gave us a battling, huge victory in the chase for Champions League qualification, and secured a top-six finish in the process.
Rob Holding's first-ever Premier League goal gave us the lead in the first half, only for the hosts to cancel it out just before half-time.
But Gabriel's header at the far post in the second half was enough to clinch all three points and keep us in fourth place.
After a fairly quiet opening half hour, in which neither goalkeeper was properly tested, it was Holding - in the side for the injured Ben White - who broke the deadlock.
Eddie Nketiah had earned a corner after a run and shot that Lukasz Fabianski got down well to turn wide. Bukayo Saka floated in a dangerous corner, and Holding rose highest to head in off the post.
It was his first-ever goal in the Premier League - on his 81st appearance - and it breathed life into a game that hadn't really got going until then.
We failed to build on the lead though, and West Ham came roaring back.
Aaron Ramsdale immediately made a fine save to deny Declan Rice at the near post, but we could not hold out until half-time.
Vladimir Coufal was afforded time and space on the right flank to pick out Jarrod Bowen, who took a touch before firing past Ramsdale, via a slight deflection off Gabriel.
Early in the second half there was a real heart in mouth moment when Ramsdale came tearing out of his box to meet the ball ahead of Bowen. The West Ham man went tumbling, but the decision went our way, with Bowen booked for simulation.
Shortly afterwards we retook the lead. Another inswinging corner caused problems, the ball was half cleared to Gabriel Martinelli and he crossed for compatriot Gabriel to head in from close range.
As the game entered the final 20 minutes we had a glorious chance to score the third. Mohamed Elneny spotted Nketiah's run from deep and released him with a long pass. The striker shifted it past Kurt Zouma, onto his right foot, but placed his shot just wide from 20 yards.
The hard-working Nketiah had another chance from similar range soon afterwards, but this time Fabianski got down to save well.
Sambi Lokonga blazed a shot over late on, but it didn't matter. The work had been done, and victory was savoured at the end by the vociferous travelling fans.
European football for next season is assured - now to make sure it's in the Champions League.
WHAT IT MEANS
There are now just four game left in the Premier League this season - 12 points to play for.
We're back at the Emirates next weekend for our penultimate home game, to take on Leeds United on Sunday.
Copyright 2023 The Arsenal Football Club plc. Permission to use quotations from this article is granted subject to appropriate credit being given to www.arsenal.com as the source.