The Whites led an all-action game 2-0 going into stoppage time but the Iron managed to level in the 11 minutes of overtime.
It was high-octane stuff with both goalkeepers making big saves early on to set the tone for a rollercoaster match.
Leeds were the more controlled side and deservedly led after 26 minutes with a goal started and finished by Ao Tanaka, his shot flicking off Axel Disasi over goalkeeper Alphonse Areola.
Apart from some dangerous attacking bursts by Adama Traore, West Ham were laboured. They were booed off at half-time, Nuno Espirito Santo responding by sending on Tomas Soucek and Pablo Felipe to switch to a 4-4-2 formation.
The move paid dividends as the home side got some momentum and went close when Taty Castellanos headed a cross against a post. Leeds who had lost the influential Anton Stach, Joe Rodon and Noah Okafor to injury were rocking, but clung on to their lead.
Reinforcements arrived with a triple substitution to stem the tide and within minutes the Whites doubled their advantage. Richard Kilman ploughed into Brenden Aaronson, Dominic Calvert-Lewin scoring from the spot with 15 minutes of normal time remaining.
That was the cue for many home fans to head for the exits while the 9,000 Leeds supporters started to roar through their repertoire of Wembley songs.
Leeds were coasting towards the last four of a competition they have only won once – in 1972 – until 11 more minutes of time was added. That gave Hammers life and rattle Leeds.
Three minutes beyond the 90 Bowen smacked the woodwork and Mateus Fernandez slotted in the rebound. Game on. Three minutes later Traore’s left-wing cross was converted by the boot of Diasi. Not for the first time this season Leeds had failed to hold on to a lead deep into a game.
The drama continued in the first period of extra time with the Hammers having two goals disallowed for offside and Leeds’ Illia Gruev denied by a goal-line block and Willie Gnoto blazing the loose ball over the bar.
As the madcap epic hurtled towards penalties there was another twist. Areola was injured after an awkward landing so third choice keeper Finlay Herrick came on for his debut and into the penalty spotlight.
The 20-year-old, who faced York City while on loan at Borehamwood earlier in the season save the first kick of the shootout from Joel Piroe, but Jarrod Bowen immediately failed to beat Lucas Perri who then went on to save from Pablo leaving Pascal Struijk to secure a 4-2 penalty win and semi-final against Chelsea.
Leeds boss Daniel Farke said: “I’m just proud of my boys, how we dealt with so many setbacks, not just the two late goals but injuries. We missed the first penalty but we stuck together.”