Danny Hylton's late cracker was enough to earn Aldershot a first appearance in the fourth round of the Carling Cup.
Goals either side of half-time from Rochdale top scorer Ashley Grimes and Shots striker Michael Rankine - his third of the season - looked like sending the game to extra time.
But striker Hylton grabbed his fifth of the season with a sublime volley 12 minutes from time.
That sent the lowest-ranked side left in the competition into the next round.
Grimes almost opened the scoring in the first minute but had to wait until just before half-time to do so, grabbing his sixth of the season with a neat finish.
Moments after the restart, however, the home side were level, Rankine equalising with a superb overhead kick as Dean Holdsworth's men looked to extend their unbeaten run to eight games.
The Shots had already beaten West Ham and Carlisle to get this far and Hylton made sure the run continued, ending Rochdale's best League Cup run since 1962 with an unstoppable effort into the top corner.
VIEWS FROM THE DRESSING ROOM
Aldershot manager Dean Holdsworth told BBC Surrey:
"I still think we can get better and they know it.
"I asked them at half-time, 'have you got the ability to play the best 45 minutes of your lives, to write history for the football club? Do you want to be part of it? How much do you want to be part of it? And its going to take some magic.
"I think they were two fantastic goals. There's a great team spirit here and I'm delighted with the never-say-die attitude."
Rochdale boss Steve Eyre told BBC Radio Manchester:
"We thought it would be won by one goal and what a good goal it was.
"We have to move on, we can't mope around because it's a tough division we're in.
"Congratulations to Dean and his team but we've got to get on with it."