Reece Burke ended Shrewsbury's hopes of an FA Cup upset as his extra-time winner edged West Ham into the fourth round.
After a goalless draw last weekend, Shrewsbury of League One held off their Premier League opposition again in normal time at the London Stadium, before Burke finally broke the deadlock in the 112th minute.
His emphatic strike, cannoning in off the crossbar, sealed an unspectacular 1-0 victory for West Ham, who will now await the winner of Bournemouth or Wigan, who play their own replay on Wednesday.
Shrewsbury had their chances, most notably through Stefan Payne's missed one-on-one with Joe Hart in the second half of normal time, but fatigue took its toll and they were playing for penalties by the end.
David Moyes made seven changes from the team that won 4-1 at Huddersfield on Saturday, with Hart in goal and Toni Martinez, who joined from Valencia as a teenager two years ago, making his first senior start.
Josh Cullen, Burke and Reece Oxford added to a youthful lineup while there was no place in the squad for the injured Andy Carroll, who has been linked heavily this week with a move to Chelsea.
Shrewsbury made three changes from Saturday's League One loss at Blackburn, a defeat which ended the club's 10-match unbeaten run. Joe Riley, Max Lowe and Payne all came in.
The first half would have been entirely forgettable were it not for Manuel Lanzini stinging the hands of Shrewsbury goalkeeper Dean Henderson, on loan from Manchester United, with a 30-yard free kick shortly before the interval.
Otherwise, it had been 45 minutes high on work and toil, but short on quality or invention, with the visitors certainly not made to feel uncomfortable and arguably even the better side overall.
As the clock ticked past the hour mark, the best chance was theirs too as Payne raced through one-on-one, only for his tame side-foot finish to be saved by Hart.
West Ham should have been punished and when Shaun Whalley shot over from another dangerous position, Moyes reacted, by throwing Mark Noble and the in-form Marko Arnautovic on off the bench.
It prompted a slight improvement, with both Arnautovic and Martinez going close in the latter stages but the goal would not come and after 180 scoreless minutes, the tie drifted into extra-time.
Noble's looping header had to be cleared off the line by Omar Beckles and Martinez found space at the near post but nodded straight into the hands of Henderson.
Shrewsbury's most dramatic escape was yet to come, however, as Lanzini looked certain to score after an Arnautovic lay-up but was instead denied, again on the line, this time by the chest of the diving James Bolton.
The underdogs were tiring and, now wasting time at every possible moment, seemingly happy to settle for penalties but their hopes were dashed eight minutes from the end.
After failing to clear their lines, the ball landed for Burke 12 yards out and he banged it sweetly off the underside of the crossbar and into the net. West Ham were relieved to hear the final whistle blow.