Shrewsbury recovered from the shock of conceding an early goal to take another major step towards automatic promotion.
The Millers, with manager Steve Evans taking charge for the first time, went ahead when Ryan Cresswell headed home after a corner.
Terry Gornell equalised with a low shot from 20 yards past Rhys Taylor and the Shrews, unbeaten at home in 30 matches, went ahead when Aaron Wildig tapped in.
Gornell made sure of the points with another shot into the bottom corner.
VIEWS FROM THE DRESSING ROOM
Rotherham United manager Steve Evans told BBC Radio Sheffield:
"When you play the top sides, it doesn't matter how much of the ball you've got or possession, if you make mistakes you'll be punished.
"We got a good start and it is a shame really because we should have been three up [at half-time]. The game should have been over as a contest.
"When young Tommy [Newey] makes a mistake, they work it and get a goal from that."