Ether Gonzalez's opener had the hosts heading for an early exit, but Ella Toone rescued the Lionesses six minutes from the end of normal time before Stanway's winner took England into the last four of a fourth consecutive major tournament.
Sarina Wiegman's side will face Sweden or Belgium in the last four on Tuesday.
England were given a boost pre-match with the return of Wiegman to the touchline after she tested negative for coronavirus earlier in the day.
The Lionesses had everything their own way in the group stage as they plundered 14 goals without reply against Austria, Norway and Northern Ireland.
However, despite their own struggles to reach the knockout stages, Spain were a big step up in class.
La Roja had been pre-tournament favourites before injuries to reigning Ballon d'Or winner Alexia Putellas and all-time top goalscorer Jennifer Hermoso rocked their preparation.
Jorge Vilda's side suffered their first defeat since 2019 to Germany in the group stage, but even in that game dominated possession of the ball.
Spain's ability to keep the ball off the hosts frustrated England and another sell out crowd of 29,000 in Brighton for the vast majority of the first 90 minutes.
But they again struggled to turn their possession into goals.
Despite being on the back foot, the home side could have led before the break as Ellen White smashed a loose ball from a free-kick into the roof of the net only to be flagged offside.
England have still never lost in now 18 games since Wiegman took charge in September.
But they have never come so close to defeat in that time and had to show admirable fight to battle back from a goal down.
Spanish substitute Athenea Del Castillo jinked past Rachel Daly and squared for Gonzalez, who had time to take a touch before firing low into the far corner.
Mary Earps then had to make a brilliant save to prevent a cross from the lively Del Castillo floating into the far corner to double Spain's lead.
Wiegman did not waste time in turning to her bench with White, Fran Kirby and the tournament's top goalscorer Beth Mead surprisingly sacrificed for the introduction of Chloe Kelly, Alessia Russo and Toone.
Those changes had the desired effect to keep England's hopes of a first major tournament win in the women's game alive.
Lauren Hemp's cross was headed down by Russo for her Manchester United teammate Toone to fire in from close range.
Suddenly the momentum completely swung in England's favour and six minutes into extra-time they led.
Stanway drove forward before the Bayern Munich-bound midfielder smashed the ball past Sandra Panos from outside the box.
Aitana Bonmati came closest to a reply when she fired wide early in the second period of extra time.
But Spain's wait to win a knockout game at a major women's tournament goes on.