Jak McCourt headed a last gasp winner to give Jack Lester a first win for the club as manager in the Checkatrade Trophy.
Spireites started well as Diego De Girolamo scored his first Spireites goal early on before, in the second half, Will Vaulks levelled for Rotherham United.
The manager made five changes from the side that lost at the weekend, Joe Anyon, McCourt and Andy Kellett came in as did fit again Joe Rowley for his first minutes of the season plus back from suspension Bradley Barry.
Sam Hird was named as one of Spireites five substitutes but picked up a knock in the warm up so Jordan Sinnott deputised.
Chesterfield had lost their opening group game, 4-2 at home to Bradford City whilst Millers opener was a 1-1 draw here against the youngsters from Manchester City; Brighton loanee Richard Towell was the only Rotherham man that started in Paul Warne's side's win at home to Northampton Town three days earlier.
Two Millers men, Akeem Hinds and Emmanuel Onariase, were making their club debuts whilst Alex Bray started for the first time.
Towell got the game's first shot in following Anthony Forde's right sided free kick in the fourth minute and Anyon had to race to the edge of his box to gather ahead of Jerry Yates soon afterwards in what was predominantly a cagey opening to the game.
Spireites took the lead in the ninth minute when Barry fed right-sider Rowley and his ball towards De Girolamo, playing as one of two strikers in a 4-4-2, took a deflection which held it up kindly to allow the Blades loanee to chip former Chesterfield keeper Richard O' Donnell and give his home town team a great start.
The goal knocked the wind out of The Millers sails, Chris O'Grady playing against one of his previous clubs, delivering the next shot, saved by O'Donnell on 21, United not mustering their next shot until 25 when Ian Evatt blocked and McCourt put the ball behind for a corner that didn't trouble the all-blue rearguard.
Jonson Clarke-Harris hit the wall from a central free kick and that ended United's first half shots as the visitors looked solid, playing with pragmatism at the back and with Rowley and Jordan Flores always looking capable of causing problems down the flanks.
Ben Wiles came on at the break for Millers for his senior debut. McCourt hit a long range pile driver just over within a minute of the restart and Rowley just couldn't find the space for a shot as Spireites came out of the traps quickly.
De Girolamo and O'Grady were both crowded out following a Barry ball in ahead of Clarke-Harris heading just over at the other end. Sinnott came on for Rowley who'd made a promising return after recovering from a broken collar bone picked up in the pre-season trip to Portugal.
Clarke-Harris forced a decent save from Anyon just shy of the hour mark as Rotherham began to build up some pressure and they strengthened their side bringing on David Ball and Joe Newell.
O'Grady and Ian Evatt had efforts in the same Spireites attack, blocked and across the face the results and Sinnott drove inches wide from 25 yards as the game began to really open up. Kristian Dennis are on for De Girolamo with 20 minutes remaining but the next action saw Millers level, Vaulks firing home from close range after a free kick was nodded down, his first goal since his Millers debut in August 2016.
Three consecutive corners for Rotherham kept the pressure on Spireites defence, but none of them was overly dangerous, but the pressure was building and sub Ball, who scored for Fleetwood against Chesterfield in The Northern Final of this competition in 2014, curled one just wide of the upright.
Dennis ran well to receive a Barry throw but his pull back just eluded O'Grady as Spireites sought to build some pressure of their own and Dennis hit high at the end of an excellent break from Chesterfield, with McCourt and Sinnott playing key roles in the rapid, flowing counter-attack.
Another quality attack led to Spireites 89th minute winner, a close range bullet header from McCourt from Flores's inch perfect cross from the left to mean Spireites have plenty to play for in the final group game against Manchester City on November 29 at The Proact.
Rotherham: O'Donnell, Emmanuel, Vaulks, Ajayi, Forde, Towell (Wiles HT), Clarke-Harris (Ball 64), Yates, Bray (Newell 64), Onariase, Hinds. Subs (not used): Bilboe, Mattock, Kayode, Murr.
Goal: Vaulks 71
Chesterfield: Anyon, Bradley, Evatt, Wiseman, Kellett, McCourt, Weir, Flores, Rowley (Sinnott 57), De Giralamo (Dennis 70), O'Grady. Subs (not used): Jones, Mitchell, Ugwu.
Goals: De Girolamo 9, McCourt 89
Ref: Darren Handley (Lancs)
Attendance: 2043 (227 from Chesterfield)