Joe Pritchard made an excellent reaction to bag a first half header, after the Hammers had capitalised on a defensive lapse to take an early lead.
The visitors regained the upper hand just before the break, but when Nathan Oduwa restored parity for a second time from the spot with 10 minutes remaining, the game could have gone either way.
It was the Hammers, though, who claimed the victory in the closing moments, as the lads dropped points for the first time this season.
We got off to a disappointing start, the Hammers taking the lead after two minutes. Advancing goalkeeper Luke McGee tried to clear his lines after a short back-pass, but his attempted clearance struck Jordan Brown, and the ball fell kindly for Kieran Bywater to slide into the unguarded net with 90 seconds on the watch.
Kyle Walker-Peters’ cross from the right sailed just beyond Oduwa at the back post as we applied pressure, while Cy Goddard curled a free-kick around the wall but wide after Emmanuel Sonupe was brought down 25 yards out.
We levelled in the 13th minute, Pritchard reacting quickest to head the ball home after Daniel Akindayini latched onto a through ball from Goddard and saw his low shot loop back up off Hammers goalkeeper Sam Baxter.
We enjoyed a sustained period of pressure in the moments that followed, but were unable to find a breakthrough, with Pritchard firing over the bar, and Akindayini trying his luck with a shot that didn’t pose any real problem for Baxter.
Hammers forward Brown went close in the 37th minute when he seized possession in midfield and let fly from the edge of the box, only to see his effort creep wide of the back stick, while our left-back Connor Ogilvie tried his luck from similar distance at the other end, with Baxter making a routine take.
The visitors regained the lead two minutes prior to the interval, with Brown finding Josh Cullen on the right side of the 18-yard box, who in turn set up Bywater to find the bottom corner of the net.
West Ham launched another attack straight from kick-off as the second half got underway, with centre-half Cameron Carter-Vickers forced to head the ball over his own bar at the expense of a corner as Djair Parfitt-Williams pulled the trigger from an acute angle.
Keeper McGee prevented the Hammers from increasing their lead in the 48th minute, expertly diving to his right and powerfully palming the ball away to deny Moses Makasi.
Akindayini shot wide from inside the area for us following a good move down the left, while Oduwa’s high free-kick sailed well beyond everyone in the area after Sonupe was fouled in the right wing position.
McGee made another fine save from Cullen, after the Hammers midfielder had robbed Josh Onomah of possession on the half-way line and advanced unchallenged to the edge of the box.
We then made a double change with Anton Walkes and Anthony Georgiou entering the fray, while Onomah was well off target from 25 yards as we sought a leveller.
We finally got our breakthrough on 80 minutes, winning a penalty after Oduwa was tripped in the box by Lewis Page. Oduwa took the kick himself, confidently despatching the ball into the bottom corner.
Two minutes later, as we chased a winner, Onomah’s shot was blocked amid a crowded penalty area, before the same player hooked over the bar after getting a second bite of the cherry from the rebound.
Akindayini then fizzed a low ball across the goalmouth, but nobody was there to tuck it home.
West Ham clinched the winning goal with three minutes to go. Both sides lost possession in midfield in the build-up, and ultimately it was Ben Marlow who emerged with the ball, driving forward and passing to the feet of Brown, who was allowed time and space to get his shot away, the ball nestling into the far corner despite McGee getting his hands to it.
The final opportunity fell to the Hammers also, with substitute Marcio Martins hammering wide of the near post after a counter attack by the visitors.
Spurs: McGee, Walker-Peters, Ogilvie, Pritchard (Walkes 61), Carter-Vickers, Maghoma, Sonupe (Georgiou 61), Onomah, Akindayini, Goddard (Harrison 71), Oduwa. Sub not used: Whiteman.