Claude Puel's charges laboured throughout the majority of the first half but went on to take the lead in the 43rd minute when Islam Slimani's ball over the top was controlled and slotted home by Kelechi Iheanacho.
The Nigerian striker then doubled his tally and put Leicester two goals ahead in the 78th minute after latching on to Riyad Mahrez's reverse pass and neatly slotting into the back of the net.
Although the goal was initially disallowed, VAR confirmed that Iheanacho's back foot was level with Fleetwood defender Nathan Pond and thus onside, reversing the linesman's decision and putting the Foxes out of reach.
The Premier League strugglers were held to a goalless draw in normal time and seemed unable to break the deadlock with penalties on the horizon.
However, West Ham succeeded in scoring 112 minutes into the match when Reece Burke rifled home with a half-volley, earning his first goal for the club and putting the Hammers into round four.
Neil Warnock's side eventually edged back in front on 66 minutes through Junior Hoilett before further goals from Anthony Pilkington and Hoilett saw the visitors secure a glamorous home tie against Manchester City.
Jos Luhukay's side will play fellow Championship side Reading, who made light work of fourth-tier side Stevenage thanks to Jon Dadi Bodvarsson's hat-trick in a straightforward 3-0 win at the Madejski Stadium.
Results in full: Leicester City 2-0 Fleetwood Town, Mansfield Town 1-4 Cardiff City, Sheffield Wednesday 2-0 Carlisle United, West Ham United 1-0 Shrewsbury Town (AET), Reading 3-0 Stevenage