In an action-packed game, David Moyes' side emerged victorious thanks to a late, late strike from substitute Arthur Masuaku.
Goals from Thiago Silva and Mason Mount either side of a penalty from Manuel Lanzini had the Blues 2-1 up at half-time.
Jarrod Bowen then equalised for the Hammers in the second half, before Masuaku earned the team all three points with a rather freakish winning goal.
The defender tried to cross the ball into the box, but miscued his effort. However, the strike was on target and completely deceived Edouard Mendy in the Chelsea goal, who should have done a lot better.
West Ham vs Chelsea Match Reaction | Football Terrace
Take a look at the bizarre match-winning goal here...
Video: Masuaku's freakish winner vs Chelsea
Oh dear, Edouard. The Senegalese international anticipated a cross and then couldn't adjust his body in time to save Masuaku's effort (which may have taken a small deflection) from 32 yards out.
It was a rare game to forget for Mendy, who's been outstanding 99% of the time since arriving at Stamford Bridge from Rennes.
The goalkeeper was the man who gave away the penalty courtesy of a very clumsy tackle after failing to properly deal with an under-hit back pass from Jorginho.
Mendy could do nothing about Bowen's stunning equaliser, though. The former Hull City forward's left-footed shot flew into the bottom corner and no goalkeeper on the planet would have got anywhere near it.
Video: Bowen's stunner vs Chelsea
Pick that one out!
It really was a match to remember at the London Stadium, one which has added yet more drama to the Premier League title race as we enter the busy festive period.
West Ham's place in the top four is also safe for now and they don't look ready to surrender it to a member of the chasing pack anytime soon.