Following a resounding Premier League 2 win over Brighton & Hove Albion Under-23s and progression in the Papa John's Trophy, City continued their momentum at home, despite playing 80 minutes of the Premier League 2 Division 1 encounter with 10 men.
The Foxes were dealt an early blow when Vontae Daley-Campbell was shown a straight red card in the 10th minute for a late challenge on Oladapo Afolayan.
City had lined up in a 4-2-3-1 formation for the clash against the Hammers with Admiral Muskwe sitting in behind lone striker Islam Slimani, but soon reverted to a 4-4-1 system after losing Daley-Campbell.
Fellow first team players Demarai Gray and Ricardo Pereira also started the game, the latter of whom featured for 60 minutes on his first appearance since March due to an ACL injury.
The 10 men rallied and created the first real chance of the game, via Gray's corner, which after being headed by Shane Flynn, cannoned off Gonçalo Cardoso and into the arms of Nathan Trott.
At the other end, meanwhile, Emmanuel Longelo's low drive was flicked towards goal by Afolayan, who just missed the post.
West Ham captain Longelo then had another low attempt tipped wide by Jakub Stolarczyk, in what was an open first period of the game.
It would be Gray who made the breakthrough on 22 minutes, slotting the ball beyond Trott after great work from Khanya Leshabela to drive through the middle and feed the winger, who used his pace to get beyond the West Ham backline.
Chances early in the second half were few and far between, though when the space opened up for West Ham centre-back Jamal Baptiste, he strode forward and struck the ball wide.
The Foxes continued to be solid until after the hour mark, when Daniel Chesters raced into the box and was brought down by the onrushing Stolarczyk.
The referee had no hesitation in pointing to the spot and Afolayan made no mistake from the resulting penalty, sending City's 'keeper the wrong way to equalise on 66 minutes.
The visitors then went close to taking the lead for the first time when goalscorer Afolayan tried to turn provider, finding Kai Corbett, who rattled the post with his fierce left-footed strike.
Longelo once again hit the upright from a curling, 25-yard free-kick that clipped off the near post and out of danger.
City were searching for the winner themselves and went agonisingly close via Flynn, whose low effort was heading in, but for a goal-line clearance from Bernado Rosa, after Gray expertly weaved his way into the box.
Rosa was also involved at the other end when the ball sat up nicely for him to strike, but Stolarczyk was equal to it.
The game became increasingly end to end as Slimani went close and then held the ball up for Admiral Muskwe, but he got underneath his effort.
West Ham had opportunities late on to win it through Afolayan, who sent a snap shot across the face of goal and then headed over.
But Gray produced a stunning finish to snatch victory for the Foxes, once again collecting the ball from Leshabela - notching his second assist of the evening - and sliding it inside the far corner.
Major moment…
The game was very much in the balance until Demarai Gray popped up with a late winner as the clock ticked towards 90 minutes. His direct play was matched with a neat finish which ensured the three points would be staying in Leicester.
Who impressed?
Sean St. Ledger said: "Demarai [Gray] was a threat all night with his speed and how direct he was and he was the difference between the two sides in the end I thought."
Where does it leave us?
The Foxes rise above Southampton and Arsenal into 10th in the Premier League 2 table, on nine points from the first seven games.
Coming up…
Next up for City's Development Squad in the league is a trip to Hotspur Way to face Tottenham Hotspur Under-23s on Monday 30 November (12pm kick-off).
The details…
City: Stolarczyk; Ricardo (Godsmark-Ford 59'), Daley-Campbell, Nelson, Flynn; Leshabela, Wright (c); Suengchitthawon (O'Connor 11'), Muskwe, Gray (Hulme 87'); Slimani.
Subs not used: Doherty, Fitzhugh.
Goals: Gray 22', 87'
All times GMT.