Striker Iheanacho claimed his 16th career goal in the competition as the 2021 winners avoided a major upset at the expense of the club languishing at the bottom of the English Football League.
Gillingham, watched by new owner Brad Galinson, set aside their miserable league campaign to provide a stern test for Premier League opposition at MEMS Priestfield but never really looked like pulling off a shock.
Dom Jefferies went closest for Neil Harris' hosts, while Gills goalkeeper Jake Turner ensured a nervy finish for the Foxes with a string of impressive saves to keep the game in the balance.
Leicester arrived in Kent on the back of three successive top-flight defeats, ready to take on a beleaguered team sitting 79 places below them in the football pyramid.
Foxes boss Brendan Rodgers made eight changes for the tie and watched his side dominate a tight opening period but struggle to break down dogged hosts in blustery conditions.
Jamie Vardy, one of the three men retained, was restricted to just eight first-half touches and left frustrated after being denied a sixth-minute opener by Gills keeper Turner following a fine pass from Marc Albrighton.
Gillingham have gone 12 league games without a win, dating back to October 1, in a dismal 2022-23 season which has brought only seven goals.
The club's biggest attendance of the season enthusiastically welcomed a new dawn ahead of kick-off as American businessman Galinson was introduced on the pitch following his recent takeover.
Midfielder Jefferies threatened just after Vardy's chance, forcing Foxes keeper Daniel Iversen to parry his powerful low drive during an encouraging first 45 minutes for the Gills.
Iheanacho later curled narrowly wide at the other end, while Turner was alert to tip over Albrighton's dipping effort just after the restart.
Gillingham's resistance was eventually broken 11 minutes into the second period.
Youri Tielemans' cross from the right was turned back across goal by Kasey McAteer and, following a touch from Vardy, the unmarked Iheanacho lashed home only his second goal of the season.
Vardy almost doubled the visitors' lead after racing clear but a strong hand from Turner pushed the ball around his left post.
Leicester had a number of promising openings to seal progression, with Iheanacho and Vardy each squandering opportunities to combine.
Yet the Gills, who defeated non-league sides AFC Fylde and Dagenham & Redbridge to reach this stage, remained hopeful going into five minutes of added time.
The Foxes stood strong during the additional period to put their name in the hat for the next round and will swiftly turn their attention to Tuesday's Carabao Cup quarter-final at Newcastle.
Gillingham, meanwhile, resume their survival mission at home to Hartlepool next weekend, sitting five points from safety.