Stanley let a two-goal lead slip as Bury sealed a spot in the last eight of the Checkatrade Trophy.
Jordan Clark and Billy Kee were on target as the Reds raced into a two-goal lead inside 38 minutes but League Two side Bury were clinical in the second half.
It was a fast paced opening from both sides and Stanley took the lead on 10 minutes.
After a quick break, winger Clark got the ball on the edge of the area and curled it beyond the diving Joe Murphy into the top corner of the net.
The Reds had to defend a couple of goalmouth scrambles as Bury looked for the equaliser while Eoghan O'Connell volleyed over the bar on 17 minutes for Ryan Lowe's side.
Sean McConville forced Shakers keeper Murphy into two good saves while the visitor's had a great chance to level on 31 minutes but Ryan Cooney's goalbound effort was deflected wide.
Stanley's goal led a charmed life on 37 minutes as the ball bounced around the box but the Reds cleared and went straight up the other end and scored number two.
Clark's ball from the right found unmarked Kee at the far post and he stroked it home for his tenth goal of the season.
It was a lively start to the second half with Clark rifling over before Bury captain Adam Thompson headed wide.
Bury got a goal back on 55 minutes when Dominic Telford fired home, his long range effort going in off the post beyond Jonny Maxted.
And they were level two minutes later when O'Connell's shot was blocked and the ball came out to sub Nicky Maynard who powered the ball home.
Stanley looked to put themselves back in front and they piled the pressure on in the Bury penalty area with Mark Hughes heading over the bar from close range on 67 minutes.
The Reds appealed for handball at one end and then Bury went straight down the other end and scored on 75 minutes.
Maynard's ball in to the far post was fired home by Telford for his second of the game to put the Shakers ahead.
Bury were on the hunt for the fourth with Maynard's strike hitting the post and bouncing out while Jay O'Shea's fierce strike was narrowly off-target.
Murphy superbly denied Stanley sub Erico Sousa on 80 minutes but Danny Mayor made it safe on 84 minutes with a strike from the outside of the area into the bottom of the net.