Scott McGleish struck a brilliant fifth minute winner to continue Northampton's impressive record of late winners against higher division sides in cup competitions.
The Cobblers have now beaten seven sides above them in the league ladder in the last 15 months - but must now focus on getting things right in the league.
McGleish's goal came out of the blue as he turned to sweetly bury a 25-yard left-foot shot into the bottom corner.
Barnsley goalkeeper Ross Turnbull then made important stops to twice thwart Josh Low as the home side called the shots in the early stages.
At the other end Robbie Williams curled a left-foot free-kick over the crossbar.
But that attempt was an isolated one and it took the Tykes until the 54th minute to have an effort on target when Tom Williams fired a drive which forced Lee Harper into a diving save.
Turnbull was undoubtedly the busier of the two goalkeepers and performed heroics in the 31st minute when he pushed away a blistering strike from Low, while Tommy Jaszczun got forward from defence but was unable to control his shot.
The visitors stepped up the tempo in the second half, having been forced to introduce Nigerian striker Folawiyo Onibuje for the injured Barry Conlon, while Dale Tonge replaced Williams at the start of the second half.
Manager Paul Hart's final replacement was forced on him when Anthony Kay was lectured by referee Ste Tanner only minutes after being booked for a foul on Lee Williamson and Hart hastily withdrew his midfielder.
Barnsley's pressure never reached fever pitch, but they did suggest they might salvage the tie only for Chris Shuker to fire a 78th minute free-kick over the bar, while Matt Carbon, thrown into attack as part of a dramatic late push, let fly with three minutes on the clock only to see the ball clear the crossbar.