West Ham had a disallowed first-half goal and came from behind to move three points clear of the relegation zone, denting Chelsea's bid for a top-four finish in the process.
Story of the match
The visitors had the game's first effort on target inside five minutes, Marcos Alonso testing Lukasz Fabianski with an acrobatic effort following a corner kick.
Frank Lampard's side dominated possession during the opening stages, and they forced West Ham's 'keeper into action again early on, the Polish shotstopper denying Willian's curled strike.
The home side responded and their first opportunity was a golden one, high-pressure creating an opening for Michail Antonio, although the lone forward lacked composure and dragged his effort wide.
Chelsea's domination continued throughout the first-half, and they came inches from an opener on 20 minutes when in-form winger Christian Pulisic's shot just wide from inside the box.
The away team continued to dominate after the drinks break midway through the first-half, however it was the Hammers who thought they'd broke the deadlock thanks to Tomas Soucek.
Despite scrambling Jarrod Bowen's corner home, Soucek's goal was controversially disallowed by VAR, an unclear decision that would've infuriated manager David Moyes.
Insult was then added to injury for Moyes' men as they conceded a penalty minutes later, Issa Diop bringing down Pulisic in the box before Willian dispatched the spot-kick to make it 1-0.
However, justice was served shortly before half-time as Soucek found the back of the net from a corner again, no VAR intervention this time as the midfielder beat Cesar Azpilicueta to level the score.
West Ham made the better start to the second-half, and they were rewarded for their efforts as they went ahead through Antonio, the forward converting Bowen's pinpoint cross from close-range.
Chelsea responded with an immediate change, Mason Mount replacing Matteo Kovacic, although it was West Ham and Manuel Lanzini who should have got the game's second goal, the Argentine curling wide from inside the box.
Ruben Loftus-Cheek and Olivier Giroud also came off the bench for the visitors, and each player went close to equalising for their side within minutes of their introduction on the hour-mark.
The substitutions kept coming and Moyes made his first by replacing Lanzini with Jack Wilshere, the midfielder making his return from another of the many injuries that have blighted his career.
Chelsea's momentum looked to have been ended by the water break midway through the second-half, however an exquisite free-kick from Willian made it 2-2 with 70 minutes on the clock.
West Ham continued to defend their own area as Chelsea pressed for a winner, however it was the hosts who scored late through substitute Andriy Yarmolenko following a brilliantly executed counter-attack.
The Ukranian winger showed superb skill to beat Antonio Rudiger before slotting into the bottom corner to make it 3-2, and West Ham held on during injury time to secure a massive win.
VAR controversy once again
West Ham would have felt hard done by heading into the break after having had their first-half 'opener' controversially ruled out.
Michail Antonio was adjudged to have interfered with Chelsea's Kepa as Tomas Soucek poked home from a corner, a decision that would have infuriated David Moyes.
After minutes of deliberation VAR decided that the forward was in the 'keeper's eyeline as West Ham scored, despite Antonio laying prone in the box and not touching the ball, highlighting a further lack of clarity over the rules.
Huge result in Hammers' relegation Battle
West Ham are embroiled in the thick of a relegation battle, and the the win moves David Moyes' side three points clear of the drop zone.
While the result gives the Hammers some breathing space, it also importantly gives the team confidence heading into the six final games that will determine the club's fate.
Dent to Chelsea's 'Top Four' pursuit
Chelsea's bid for a place in next season's Champions League took a hit as they squandered the opportunity to move up to third in the Premier League.
Following Leicester's loss to Everton earlier in the day Frank Lampard's side were poised to climb the table, however they suffered an unlikely defeat against their London rivals and remain in fourth.