Steven Howard's strike saw Leicester City win two games in a row for the first time since April 2007.
Howard netted on 36 minutes when he slid home a Joe Mattock cross from the left.
However, City's win was soured by news that their England Under-21 defender Mattock may be out for months with a bad ankle injury.
Five minutes from the end he was stretchered off and taken to hospital for X-rays on what manager Nigel Pearson said was either a suspected break or bad ligament damage.
The Hatters missed a sitter inside 60 seconds when Anthony Pilkington blazed over from ten yards after Carl Baker's clever through ball left him one-on-one with the keeper.
But after Leon McSweeney had driven over, Stockport's bright start was tarnished when they were reduced to ten men on 19 minutes.
Matty McNeil was robbed by Howard on the edge of the box and then shown a straight red for hauling back the ex-Derby striker when he would have been clean through on goal.
Owain Fon Williams then kept his side level when he brilliantly scooped Dudley Campbell's close range shot over the bar.
But then the keeper was beaten by Howard to give City every chance of progressing to the next round.
However, it was City keeper David Martin who denied Stockport a leveller just before the break when he was at full stretch to parry Baker's 20-yard free-kick.
After the break, County threatened again when Baker's 16-yard shot drifted over Martin and onto the roof of the net.
Andy King hit back for City when he blazed just wide after Mattock had cleverly laid the ball back.
And on 75 minutes, substitute Paul Dickov shot from close range but Williams made another instinctive save.
The Foxes went closer on 84 minutes when King's 20-yard drive was touched onto the post by Williams.
But the game ended on a sad note five minutes from the end when Mattock was stretchered off after an innocuous looking challenge with Hatters substitute Peter Thompson.