Morton booked their place in the third round with a superb win over Hibernian and - despite being without a win in the Irn-Bru First Division so far this season - looked set for another SPL scalp at Cappielow.
Jim McAlister claimed the only goal of the first half only for Richard Hastings to level with just 11 minutes to go to force the tie into extra-time.
Caley Thistle needed penalties to overcome Arbroath last time around but Imrie's strike ensured such a scenario would not be necessary this time.
The opening 45 minutes of this clash was a largely uninspiring affair.
The first real shot on goal arrived with more than 15 minutes on the clock when Don Cowie produced a weak effort that did little to trouble Kevin Cuthbert in the Morton goal.
The goalkeeper then had to deal with a poor passback from Chris Smith, which he managed to control on his chest with no Inverness players lurking to cause him any problems.
Morton's first chance came courtesy of Ross Tokely conceding a foul on the left flank. Steven Masterton whipped the free-kick across the face of goal and Iain Russell was only inches from connecting at the far post.
Ryan McGuffie then found himself dispossessed in the middle of the park, gifting Inverness a shot at goal, but Garry Wood dragged well wide from 40 yards.
The breakthrough came after 33 minutes and it was the home side who were celebrating when Brian Wake supplied the cross and McAlister bundled home from all of four yards.
Inverness made a change at the break, Rory McAllister making way for the introduction of Barry Wilson, as the Highlanders attemped to force their way back into the tie.
Instead, it was the home side who should have extended their lead shortly after the restart.
McAlister embarked on a decent run on the left flank, racing past Jamie Duff, before rifling at goalkeeper Ryan Esson, who managed to clear for a corner with McGuffie loitering with intent on the line.
Morton then had another chance to put the tie out of Inverness' reach when Russell Duncan fouled Wake just outside the box and Masterton's curling free-kick was only denied the back of the net by an excellent block from Esson.
The Greenock side were left ruing those misses when Inverness hauled themselves back onto level terms with 11 minutes to go when Hastings threw himself in front of a deep cross from Tokely and nodded home the equaliser.
With the the tie in extra-time, Wood drew a point-blank save from a close-range volley, before substitute Adam Rooney saw his effort flash just wide of the upright.
But it was Imrie who claimed the decisive goal after 111 minutes with a sweet strike from 15 yards to provide Craig Brewster's men with reason to celebrate on the long journey home.