Gareth Bale scored yet another brilliant last-gasp winner to move Tottenham up to third after a cracking London derby at Upton Park.
Jussi Jaaskelainen rolled back the years to keep the Hammers in the game for most of the clash, but there was nothing the 37-year-old could do to stop Bale's blistering 25-yard shot flying in to the top corner with just 10 seconds remaining.
Bale put Tottenham ahead in the first half, but Andy Carroll scored a penalty after being brought down in the box by former Hammers midfielder Scott Parker, who was booed throughout.
Joe Cole thought he had grabbed the Hammers a morale-boosting win with a goal against the club he almost joined last season, but substitute Gylfi Sigurdsson equalised and Bale provided the killer blow in the final minute.
West Ham dominated for large parts of what was a pumped-up derby, but as has been the case in so many games of late, there was always the chance that Bale could pull off another bit of magic to settle the game.
How Andre Villas-Boas must hope he is able to hang on the man who is in the best form of his already stunning career. The victory proved extra sweet for Villas-Boas as his team have dislodged his former employers Chelsea from third place.
West Ham used the 20th anniversary of Bobby Moore's death as an inspiration to start the game well. Led out by three of Moore's grandchildren, the Hammers started in combative mode, with Gary O'Neil clattering in to Emmanuel Adebayor.
Mousa Dembele seemed just as pumped for the occasion, taking out Kevin Nolan to earn a booking. West Ham were on top for the first 10 minutes, with Mohamed Diame and Matt Jarvis both drawing saves from Hugo Lloris.
Bale shot wide early on and teed up Aaron Lennon, whose shot took a deflection which Spurs thought struck a West Ham hand in the box. Bale, like Parker, was subjected to jeers from the home fans, but he had stunned the West Ham faithful with the opener after 12 minutes.
The Welshman, operating up front alongside Adebayor, gained a yard on James Collins and another two Hammers defenders before firing across Jaaskelainen into the back of the net.
Bale led a rampaging Spurs break soon after but he shot tamely, much to the frustration of the unmarked Jan Vertonghen, who was screaming for the ball at the far post.
Soon after Spurs were made to pay thanks to Carroll's second goal of 2013. Parker put in an ill-advised two-footed challenge on Carroll in the box and Howard Webb pointed to the spot. The former Newcastle striker picked himself up, smashed the ball past Lloris and waved two fingers towards the away support, who had previously goaded him by claiming he was only capable of scoring once a year.
The crowd lapped up what was turning in to a thrilling end-to-end contest.
West Ham had a reasonable appeal for a penalty turned down when Vertonghen impeded Carroll.
The Hammers remained on top and would have gone ahead just before the break had Kyle Walker not put in a brilliant block to deny Jarvis.
Bale still looked capable of changing the course back in to Tottenham's favour, though, the Welshman cracking one of his trademark swirling free-kicks just wide. Spurs almost took the lead again just after the break when Vertonghen's shot flew off Guy Demel's leg, but Jaaskelainen scrambled across his line and tipped wide.
The big Finn then saved brilliantly to tip Sigurdsson's shot on to a post and he quickly regained his ground to save Adebayor's follow-up.
West Ham still had the majority of possession and they made it count with their second just before the hour. Cole timed his run to perfection, gaining two yards on Steven Caulker before slotting past Lloris and removing his shirt in a wild celebration. Sam Allardyce almost spilled his cup of tea in another raucous celebration on the Hammers bench.
Spurs threw everything at the hosts and had it not been for another two outstanding saves by Jaaskelainen from Bale and Caulker, they would have retaken the lead. Lloris pulled off a top-drawer save of his own when Matt Taylor beat the offside trap and fired on goal.
The save proved crucial as Tottenham went up the other end and equalised. The Hammers failed to deal with Bale's free-kick, a melee ensued in the box, but Sigurdsson held his nerve to poke past Jaaskelainen from close range.
Jaaskelainen pulled off another two top-class saves to deny Adebayor and Sigurdsson as the clock ticked towards 90 minutes. Then with 10 seconds left the man of the moment picked himself up after being flattened by a tackle, collected the ball off Tom Carroll and let fly with an audacious 25-yard bullet that beat Jaaskelainen.