The Millers took a fifth-minute lead when Nicky Law’s shot was deflected past his own keeper by Paul Rodgers. They went on to dominate the first half, with Mark Bradley just off target while Tom Newey saw his free-kick tipped around the post by Steve Collin.
Rotherham doubled their advantage on the stroke of half-time when Northampton failed to clear another cross and Jason Taylor pounced to fire home from 15 yards.
Northampton boss Gary Johnson threw on Michael Uwezu and Leon McKenzie at the start of the second half in a bid to get back into the game.
It was the substitutes who combined to reduce the arrears in the 68th when Uwezu shot against the foot of the post and in the ensuing scramble McKenzie forced home the rebound from close range.
Northampton piled on the pressure in the closing stages and in the second minute of stoppage Rotherham could only partially clear and Davis struck a low drive through a crowded box to send the Sixfields crowd wild.