The Foxes had lost their last two games against Manchester City and Liverpool but moved four points clear of Pep Guardiola’s side once more in second spot following victory in the capital.
Brendan Rodgers made nine changes from the side that was hammered by Liverpool on Thursday evening, with only Kasper Schmeichel and Jonny Evans surviving the cull.
Leading goalscorer James Vardy was among those missing from the matchday squad after he became a father again earlier in the day.
Kelechi Iheanacho put Leicester in front on 40 minutes but the Hammers were level before the break via Pablo Fornals.
Demarai Gray got what would prove to be the decisive goal 11 minutes into the second half, with West Ham missing the chance to move away from the relegation zone following losses for Bournemouth and Aston Villa earlier in the day.
The absent Vardy will have cursed his luck on 10 minutes as he missed out on a goalscoring chance from the penalty spot.
Iheanacho was felled by Lukasz Fabianski but the West Ham stopper made amends when he pushed away Gray’s effort from spot.
West Ham weren’t creating much at the other end although Declan Rice did draw a save from Schmeichel.
A mistake from Arthur Masuaku helped Leicester go in front. Full-back James Justin returned the ball into the penalty box and Ayoze Perez’s head put the goal at the mercy of Iheanacho.
That looked as though it would separate the teams at the break but Fornals’ sweeping finish in stoppage time levelled after good set-up play from Felipe Anderson.
The Foxes hit the front again with a superb counter-attack 11 minutes into the second half. Perez broke at pace and hurdled his way past the West Ham cover before sliding in Gray, who atoned for his earlier penalty mishap with a neat finish into the corner of the net.
Rodgers’ side were then able to hold West Ham at bay for the most part. Manuel Pellegrini’s side struggled in their pursuit of clear-cut chances and were eventually condemned to a fourth-straight home defeat, leaving a sullen atmosphere at the end.