First half goals from Sam Baldock and Julien Faubert were enough to give the Hammers a 2-0 advantage at half-time.
Typically of the Hammers though, a hard-fought second half ensued and Leicester got back into the game on the hour through Andy King.
A Sam Baldock strike regained the two goal cushion for the home side with only 20 minutes left but a thunderbolt from King cancelled it out again almost immediately to leave the Hammers hanging on to secure all three points.