Ole Gunnar Solskjaer took the opportunity to give a few United fringe players opportunities to impress but ultimately had to turn to his regulars on the bench, with McTominay the one to make the difference.
United was frustrated in the first half as they struggled to make the most of its dominance over a West Ham side who offered very little in attack, with Victor Lindelof going closest for the host when denied by the upright.
Aside from United managing fewer shots, the pattern of the match hardly deviated after the break and it was no surprise to see it remain goalless at the end of the regulation 90 minutes.
But the host's superiority told in the end with West Ham unable to cancel out McTominay's 97th-minute strike.
It quickly became apparent that West Ham's plan was to pack their defence with as many players as possible and it was nearly undone just 11 minutes in, but Anthony Martial was denied by a crucial Angelo Ogbonna intervention that resulted in the Italian sustaining an injury.
But United's best chance fell to Lindelof in the 27th minute, his header from an Alex Telles corner taking a slight deflection before Lukasz Fabianski tipped it on to the post.
West Ham lost Ogbonna's replacement Issa Diop – who had clashed heads with Martial – at half-time as the recently introduced concussion substitution was used for the first time in English football, and they soon saw Andriy Yarmolenko forced off as well, former Manchester United trainee Ademipo Odubeko replacing him.
United wasted another chance a minute before Yarmolenko's exit, as Fabianski rushed out to thwart Marcus Rashford after Mason Greenwood's low cross was deflected through.
Extra-time was inevitable despite the likes of Bruno Fernandes and Edinson Cavani coming on, but a penalty shootout was not necessary, with McTominay running on to Rashford's smart lay-off and rifling a low volley into the bottom-right corner.