Alex Fisher headed Town into the lead early on but was forced off with an injury ten minutes after Olufela Olomola also went off with an injury.
With the hosts’ rhythm disrupted Stockport turned the tie on its head within the space of four minutes, Matty Warburton struck with a free-kick and Nyal Bell turned in a cross to take a 2-1 lead into the break.
Frank Mulhern came off the bench and scored with virtually his first touch to secure the win for the visiting sixth division side.
Launching their cup campaign, Darren Way made two changes from the side that lined up in their last league outing at Morecambe.
Recovering from a virus that ruled him out of the trip to Lancashire, top scorer Alex Fisher returned to partner Olufela Olomola up front whilst Alex Pattison came in for Yoann Arquin who dropped to the bench.
In a slight reshuffle, Jake Gray moved out to the right wing as Rhys Browne took a seat amongst the substitutes.
The rain cleared up before kick-off at Huish Park and the sun came out for the impeccably observed minute’s silence.
It wasn’t long before the sun disappeared behind the clouds and shortly after that the Glovers found themselves ahead with the first real chance of the match.
A ball was crossed into the box by Carl Dickinson towards Fisher and the number nine looped his header over Ben Hinchcliffe to give the hosts the lead.
Not deterred through conceding an early goal the Hatters found themselves two-on-one with Bell bearing down on goal.
The striker had Adam Thomas to his left but chose to shoot from range, sending the ball wide of goal and failing to capitalise on a golden opportunity.
Town breathed a sigh of relief when Bell missed another chance, controlling in the area he spun his man and fired over the bar from only a few yards out.
Despite the goal lead Town were dealt a massive blow when both Olomola and Fisher had to be replaced within ten minutes of each other.
Francois Zoko and Omari Patrick replaced the attacking duo who both went down with injuries and could not continue.
With the Glovers disrupted by the early changes, Stockport drew themselves level thanks to Warburton.
The forward struck his free-kick from past the wall and past Nathan Baxter into the right corner from 20 yards to tie the game.
Not content with being level the non-league side pushed forward and matters got worse for the green and whites as they found themselves a goal behind.
Good work on the right from Elliot Osborne led to a cross into the area, Bell met the ball ahead of his man and steered the ball home to complete the four-minute turnaround.
Tom James attempted to draw the green and whites level with a free-kick from 25 yards just before the break, but his effort dipped over the wall and over the bar in the last action of the half.
Coming out motivated for the second 45 it wasn’t long before Town engineered themselves a chance.
Charging forward from defence, Shaun Donnellan slipped in Patrick wide of goal who saw his effort saved by Hinchcliffe and the follow up from Wes McDonald was blocked a few yards off the goal line by Ash Palmer.
Still trailing but dominating in possession Alex Pattison had a couple of tries from range but couldn’t find the target.
Not making their dominance in possession count the Glovers found themselves further behind.
Substitute Mulhern took advantage of a mix-up in defence and went past Baxter to tap home into the empty net.
Looking to see out the game the Hatters battered down the hatches and restricted chances for the green and whites.
From the chances they did create Hinchcliffe was on hand to prevent that happening, firstly he got down to an effort from McDonald before pulling off a fantastic save to tip Tom James’ header onto the bar to condemn Yeovil to a disappointing defeat.
Yeovil Town: Baxter; James, Mugabi, Donnellan, Dickinson; Gray (Browne 59′), D’Almeida, Pattison, McDonald; Fisher (Zoko 28′), Olomola (Patrick 19′).
Bookings: Patrick 90+3′
Subs not used: Nelson, Mahmutovic, Santos, Arquin.
Stockport County: Hinchcliffe; Minihan, Duxbury, Keane, Palmer; Cowan, Thomas, Walker, Bell (Mulhern 60′); Osborne, Warbuton (Dimaio 59′).
Bookings: Mulhern 89′, Duxbury 90+3′
Subs not used: Downing, Ormson, Stephenson, Etches, Czubik.