A partial floodlight failure left one corner of Priestfield in gloom but Gillingham shone brightly against ten-man Rotherham to move into the play-off positions.
Simon King gave the Gills an early lead and they went on to dominate the game after Danny Harrison's red card ten minutes before the break.
Adam Miller slammed home from close range to double the lead just before the hour mark and late goals from Garry Richards and Luis Cumbers sealed victory.
An electrical problem before the game ensured one of Priestfield's four pylons did not come on, but it was not serious enough for the game to be called off.
Gillingham welcomed back top scorer Simeon Jackson after missing five games with an ankle injury, but the hosts took an early lead through an unlikely source.
Nicky Southall's sixth-minute free-kick found King at the back post and the centre-back nodded home for his first goal in 66 games for the club.
Rotherham slowly imposed themselves on the game and on the half-hour mark Nick Fenton was acrobatically denied by Simon Royce.
The Millers' hopes of a first win at Priestfield in 20 years were dented when Harrison saw red on 35 minutes. The full-back went in over the top on Gills captain Barry Fuller, with the referee immediately producing a straight red.
After the break the home side made good use of their man advantage. Just before the hour mark Miller slid a ball into Mark McCammon and when the big striker collided with Andy Warrington the ball spilled back to the midfielder, who slammed home into the empty net.
Richards headed a third goal and 20-year-old Cumbers wrapped up the game with his first senior goal for the club two minutes from time.