Bury top scorer Ryan Lowe hit a late winner at already promoted Chesterfield to fire the Shakers up to League One.
Tom Lees headed the visitors ahead from Ben Futcher's cross before Craig Davies equalised from the edge of the box.
David Worrall restored Bury's advantage from close range just five minutes later, only for Jack Lester to fire in the equaliser from 12 yards.
But, just three minutes from time, Lowe kept his cool beyond the corner of the six-yard box before picking his spot.
After the superb way he has led the line all season, it was fitting that it should be Lowe, League Two's player of the year, who scored such a classy goal to seal his side's promotion.
It was the much-travelled Liverpudlian's 26th league strike of the season - taking him back level with Crewe's Clayton Donaldson as League Two's top marksman.
After a career spent largely in the Football League basement, excepting his two seasons in League One at Crewe, the 32-year-old will now be relishing the prospect of plying his trade in the third tier of English football next season.
If Chesterfield had won, they would have lifted the League Two title.
Their final two games are both against play-off chasing teams, at Torquay this Friday night (29 April, 1945 BST) before hosting Gillingham on 7 May (1.
But, although they have now win six games on the spin, Bury's final two games should prove just as tough.
They host third-placed Wycombe this Saturday (30 April, 1500 BST), before finishing the season at another play-off chasing side Stevenage.
Bury caretaker manager Richie Barker told BBC Radio Manchester:
"Ryan Lowe has been brilliant this season. 26 league goals now. I said to him before the game 'do you want a golden boot or a winners medal?' He said 'a winner's medal every day'. But, with a bit of luck, he'll get both.
"The players are desperate for a winner's medal and, from their point of view, to be two points behind and two games to go, it's an opportunity.
"I've done what I've been asked to do, I've enjoyed it and wherever I end up in six weeks' time, I can look back and say I enjoyed my month in charge."