The Cobblers got off to the perfect start when Adebayo Akinfenwa gave them a third-minute lead, scoring from close range after Rovers failed to deal with a Daniel Jones’ cross.
Alex Dyer should have increased Town’s lead after 27 minutes but he took too long after a quick break from Akinfenwa.
Antony Kay volleyed over from Shane Sherriff’s cross while Colin Larkin almost grabbed a second for Northampton when his goal-bound shot was blocked.
Chris Dunne, making his Cobblers debut in place of the injured Mark Bunn, saved well at the near post to deny Andy Taylor, but was powerless to keep out Chris Greenacre’s overhead kick after 43 minutes.
Jones went close on the hour when his free-kick was just off-target before Hubertz came off the bench to grab a 69th-minute winner, heading home a Jones free-kick.