Bale continued his red-hot form after breaking the deadlock after 13 minutes with a clinical finish. However, Andy Carroll levelled from the spot before Joe Cole put the Hammers ahead on the night the club commemorated the 20th anniversary of Bobby Moore's death.
But the visitors were not to be denied victory as Gylfi Sigurdsson restored parity before Bale's astonishing winner in stoppage time.
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 former Hammer Scott Parker, was subjected to jeers from the home fans, but he had stunned the West Ham faithful with the opener after 13 minutes. The Welshman, operating up front alongside Emmanuel Adebayor, gained a yard on James Collins and another two Hammers defenders before firing across Jussi 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 and smashed the ball past Lloris.
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 for his sixth goal in his last four Premier League matches, taking his overall tally for the season to an impressive 19.
Andre Villas-Boas' side now have all the momentum heading into Sunday's north London derby at home to Arsenal.