Marc Albrighton had given Leicester an early lead inside 10 minutes as the Foxes took advantage of poor play from the hosts, but Kouyate equalised just before the half-time whistle.
While Arnautovic was advancing well down the right-hand side for West Ham, right-back Pablo Zabaleta was at fault for his side conceding.
Vardy was almost in again, but Arnautovic, whose next cross had whistled past Carroll's head, raced back to intercept.
It was Arthur Masuaku who led the fightback for West Ham, as he was tripped following a weaving run through the Leicester midfield.
Manuel Lanzini, Kouyate and Carroll then surged forward after Mahrez had given the ball away, but Lanzini hesitated on the ball and was eventually tackled.
Masuaku, who had threatened for West Ham in the first half, was dangerous in the second period after drilling a cross then a shot at Schmeichel.
Ayew had an opportunity to win it for his side in stoppage time but his acrobatic effort graced the top of the Leicester net.
The result means that West Ham have not won in six games, with the club still in the relegation zone. Leicester are up to 11th in the top flight, four points above the drop.
West Ham (4-2-3-1): Hart; Zabaleta, Reid, Ogbonna, Creswell; Kouyate, Obiang; Arnautovic (Ayew 69'), Lanzini, Masuaku (Sakho 90+4'); Carroll
Leicester (4-4-1-1): Schmeichel; Simpson, Morgan, Maguire, Fuchs; Albrighton, Ndidi, Iborra, Gray (Slimani 90+2'); Mahrez (Chilwell 70'); Vardy