Emmanuel Adebayor had given the hosts the lead before late strikes from Matt Jarvis and Modibo Maiga turned the tie around to send Sam Allardyce's men into the last four
Mali international Maiga had gone 12 months and 17 days without scoring for West Ham but picked the ideal time to end his drought, heading home fellow substitute Mohamed Diame's cross with five minutes left to book his side's place in the semifinals.
Only five minutes earlier, winger Matt Jarvis drew the visitors level with an excellent finish from inside the box as the visitors ruined Tim Sherwood's first match in charge of Tottenham.
Sherwood – Tottenham's technical coordinator and caretaker manager after Andre Villas-Boas was sacked on Monday – saw his side take a deserved lead in the 67th minute as Emmanuel Adebayor, making his first start of the season, volleyed home Jermain Defoe's cross.
But Spurs faded dramatically after that as West Ham won at White Hart Lane for the second time in less than three months.
Tottenham had not lost back-to-back home games against West Ham since 1966 and to make matters worse, had winger Andros Townsend limp off with a left hamstring injury late on.
Sherwood made six changes from Sunday's 5-0 loss to Liverpool, which proved to be Villas-Boas' last game at the helm, and reverted to a 4-4-2 formation, as Adebayor partnered Defoe up front, while Kyle Walker wore the captain's armband with Michael Dawson suspended.
West Ham made seven changes and was on the back foot early, as Lennon charged down the right and cut back for Gylfi Sigurdsson, with Defoe shooting just wide in the second minute.
The hosts had five corners inside the first 16 minutes but dropped off after that as West Ham finally settled, although their best effort was a Carlton Cole strike from 25 yards that was easily saved.
Tottenham finally made the breakthrough with 23 minutes left when Defoe charged down the left and looped a perfect ball into the path of Adebayor, who thrashed his effort in off the underside of the crossbar to score his first goal since May.
West Ham substitute Diame tested Lloris and Matt Taylor drew two saves out of the French goalkeeper, before their pressure told with 10 minutes left.
Taylor played in Jarvis and he shot into the top left corner, before Maiga's winning header delighted the away fans.
Sigurdsson had another effort saved in injury time and Maiga was denied a second by the crossbar, but it mattered little as West Ham held on.