Fresh from booking their spot in the quarter-finals of the Champions League, the Foxes chalked up their third straight league victory as they moved into 15th position in the table and now six points clear of the relegation zone.
It took Leicester just five minutes to make the breakthrough, with Riyad Mahrez's floated cross towards Jamie Vardy and Shinji Okazaki somehow finding a route over the head of Darren Randolph, who had set himself for a header.
Less than two minutes later, it was 2-0 to the visitors as Robert Huth headed an excellent Marc Albrighton cross into the back of the net after a clever free kick from the Foxes had caught West Ham short.
It took the Hammers a bit of time to recover from the blow of losing two early goals, but the home side were back in the match in the 20th minute when Manuel Lanzini found the back of the net with a wonderful free kick from distance.
Andre Ayew twice came close to levelling the scores late in the first period, but the Ghana international dragged his low attempt wide of the post in the 24th minute, before heading an Aaron Cresswell cross over the crossbar 10 minutes later.
Instead, it was Leicester that scored the game's fourth goal in the 38th minute when Vardy took advantage of some poor defending from West Ham before slotting the ball past the isolated Randolph, which brought more groans from the home supporters.
The Premier League champions also started the second period on the front foot and Okazaki had a half-chance to make it 4-1 in the 54th minute, but the 30-year-old just could not get enough purchase on his effort.
West Ham found a response once again, however, and it was Ayew that flicked the ball home in the 63rd minute after towering centre-forward Andy Carroll had jumped highest inside the Leicester box to meet a corner.
Carroll came close to levelling the scores 15 minutes from time when his header hit the ground and bounced towards goal, but Leicester goalkeeper Kasper Schmeichel was on hand to make a wonderful save and keep the Foxes ahead.
West Ham had an even better chance 10 minutes from time when Michail Antonio released Ayew into a dangerous position, but the forward could only fire high and wide of the Leicester goal as another chance came and went.
The pressure from the home side continued into stoppage time and Carroll had another wonderful chance to level in the dying moments, but Schmeichel denied the striker once again as the English champions continued their winning run, moving to within three points of West Ham in the process.