The Hammers, reeling from four straight defeats in all competitions and amid a backdrop of discontent at their new stadium, were down to 10 men and heading for extra time against the Sky Bet League Two side.
But Payet, on as a half-time substitute, sent them through with a trademark strike in the sixth minute of stoppage time.
mercurialx black "The main thing was to go through," said Hammers boss Bilic. "We expected an easier win, with the greatest respect, and not to have to do it in the last minute.
"We wanted to progress and that's why we brought Dimitri, and Manuel Lanzini and Michail Antonio on.
"We went down to 10 men but we wanted to score before extra time and then, a great moment from a great player. We didn't play good but I thought we deserved to win.
ace 16 purecontrol red "It was not exactly what we wanted tonight - but it's a win."
It has not been a happy start to life at the London Stadium for the Hammers, but the club have taken steps to avoid the crowd trouble which marred the recent Watford game by relocating disgruntled fans and improving the stewarding.
X 16.1 sliver fg However, the promised beefed up segregation between home and away support appeared to amount to a slightly wider claret curtain draped over the seats.
new soccer shoes There will be bigger tests of those improvements than the presence of 600 Accrington supporters - not least after West Ham were drawn at home to capital rivals Chelsea in the fourth round.
Meanwhile West Ham's problems on the pitch remain as Stanley created the better chances in the first half, with Darren Randolph saving from Seamus Conneely and Jordan Clark firing narrowly wide.
After the break Sean McConville unleashed a fierce curling effort which Republic of Ireland goalkeeper Randolph had to tip wide at full stretch.
Stanley keeper Elliot Parish denied Simone Zaza a first Hammers goal with a point-blank save, and having used all three subs the labouring hosts found themselves a man down when left-back Arthur Masuaku was stretchered off.
But with extra time looming Payet won West Ham a free-kick 25 yards out and curled it home with virtually the last kick of the game to break Stanley hearts.
tiempo legend white Their manager John Coleman said: "We don't want to be congratulated for being plucky losers, we came to win the game.
"We knew West Ham were a bit fragile at the moment. People will say they haven't played well tonight, but that would be disrespectful to us.
"The players worked their socks off and I have to give them credit. But giving a foul away in that position with Payet on the pitch is tantamount to suicide."