Two first half goals from Harvey Barnes and Ricardo Pereira had the Foxes in cruise control however an early second-half penalty from Mark Noble brought David Moyes' side back into the tie.
After a spell of chances for both sides, it was the East-Midlanders who would take their chances after two goals for Ayoze Perez sealed the victory for the Champions League chasing Leicester and a first win in three games.
There will still be concern for Brendan Rodgers' side however after both Nampalys Mendy and Jamie Vardy were forced to be substituted due to injury, leaving them doubtful for the two upcoming cup ties against Brentford and Aston Villa.
Story of the Match
Foxes dominate opening stages
Brendan Rodgers' side were given the freedom of the pitch by West Ham from minute one as the side linked up well to create chances to test the Hammers' backline.
Ricardo Pereira misjudged the amount of time he had on the ball before firing a strike well wide of the post whilst Ayoze Perez also got into good positions, however couldn't muster any real goalscoring threat.
Barnes back to his best
After his goal against Burnley last weekend, Barnes has rediscovered his goalscoring touch and opened the scoring for the home side 24 minutes in after playing a slick one-two with Foxes right-back Pereira, who drilled the ball back towards the path of Barnes who tucked the ball away to make it two goals in as many games.
Injury concerns for Rodgers
It could have been a near perfect first-half for Rodgers however he had to contend with two first-half injuries, including one to Premier League top scorer Vardy.
Nampalys Mendy pulled up with an injury shortly after Barnes' effort and was replaced by the returning Wilfried Ndidi who made his first appearance since returning from a hamstring problem.
Vardy then also became a cause for concern after he indicated a hamstring problem after clearing the ball away from a West Ham corner. After initially intending to carry on playing, Vardy was quickly replaced by Kelechi Iheanacho to lower the risk of aggravating the injury.
Rocket from Ricardo
Pereira and Leicester had been in cruise control all half as West Ham struggled to threaten at the King Power Stadium and were made to pay as Pereira doubled the home side's advantage just before half-time.
Barnes this time turned provider for the Portugal international after he kept in play a loose ball before driving to the box and cutting back for Pereira, who unleashed a thunder-strike from just inside the box to fire past the helpless Darren Randolph in goal.
A glimmer of hope but Foxes take chances
The second-half started in favour of the away side after the returning Ndidi was adjudged to have fouled Sebastien Haller in the box and after a lengthy wait for VAR to confirm the decision, club captain Mark Noble halved the deficit to gift the away side hope of getting back into the game.
After both sides had chances it was Leicester who would make sure of the three points with two goals from Ayoze Perez to give Leicester a first league win since New Year's Day.
Perez's first came from the penalty spot after the lively Iheanacho was brought down by Angelo Ogbonna before the two combined again two minutes from time to cap off an excellent performance for the Foxes.
The return of Ndidi
Although it may have not been the way Rodgers planned, both him and Leicester fans will have been delighted to see the return of the Nigeria international after he has missed the last two games with a hamstring injury.
Ndidi replaced Mendy, who left the pitch shortly after Leicester's first goal, and after initially being told he would be out for three to four weeks, returned after just 11 days and looked his usual self by breaking up the play and allowing his more creative midfield partners to get forward.
Concern for Vardy
Although the result may have been perfect, everybody associated with Leicester will still leave the ground worrying about the extent of Jamie Vardy's injury. Vardy was replaced by Iheanacho after he looked to have pulled his hamstring after he attempted to clear the ball.
It's not quite clear how bad the injury is or how long Vardy could be out for, but there will be hopes that he will be fit for the Carabao Cup Semi-Final second leg against Aston Villa, with Vardy most likely to be rested against Brentford in the FA Cup.
Work for West Ham
For the home side it was a return to the type of performance that has been associated with their impressive season however for West Ham and David Moyes, the result will be of large concern.
Although the change of formation and the introduction of Michail Antonio sparked some life into the Hammers, the lack of movement and hunger in the first-half, combined with the lacklustre defending in the second-half allowed Leicester to pick off their opponents and punish them for missed chances and a slow start to the game.