Declan Rice saved West Ham from FA Cup humiliation before Jarrod Bowen inflicted a second cruel blow on Kidderminster Harriers as the Premier League visitors won 2-1 in the FA Cup fourth round at Aggborough.
Alex Penny shot Kidderminster ahead in the 19th minute after West Ham made a mess of defending a free-kick, and that looked like being enough to secure a famous win, until Rice struck an equaliser in the first minute of stoppage time.
Watched by England's 1966 World Cup hat-trick hero Geoff Hurst, Rice snatched the chance to take the game to extra time, smashing home after dashing into the penalty area and sidestepping a tired challenge.
Kidderminster dug deep in the extra 30 minutes and looked sure to force a penalty shoot-out, but the minnows were again hurt by a late West Ham goal, with Bowen tucking home a close-range finish, again in stoppage time, to take the visitors into the fifth round.
West Ham sit fifth in the Premier League, with Kidderminster third in the National League North, the sixth tier of English football. For West Ham manager David Moyes, this was a close call with embarrassment on a major scale.
Only twice in the Premier League era has a non-league team beaten a top-flight side in the FA Cup – Luton Town against Norwich City in 2013 and Lincoln City against Burnley in 2017.
West Ham knew they were close to becoming the third team on that list, and Rice admitted Kidderminster would have been good value for victory in 90 minutes.
England midfielder Rice told BBC One: "Massive, massive respect to Kidderminster. We watched some videos of them this week and they've been flying.
"We weren't at our best and scraped it with two goals. They probably deserved it, if I'm being honest. We need to improve if we want to push on, but massive congratulations to them because they were excellent.
"The fans are on top of you and they will fight for every ball. It can be a shock to the system. We know what to expect but it's hard to get to grips with.
"They were in great shape, pressed hard and they made some great substitutions but we're through to the next round so that's the most important thing."
Relieved manager Moyes said: "We got it done. We certainly scored a really good first goal to get us back in the game.
"But all the credit goes to Kidderminster for how well they played. They did a terrific job. We didn't play well.
"I think if people came here and saw the sort of conditions, they'd maybe realise how difficult it could be.
"But no excuses for us, we didn't play well enough, and for me if you were to ask me any questions it should be about Kidderminster and how well they played, and they did a great job."
Moyes hailed the contribution from Rice, saying: "Everybody knows how important he is to us."