Ben Tozer's last-minute winner gave Northampton victory and condemned Barnet to a third successive defeat.
Ricky Holmes hit the post but later put the Bees ahead with a shot from the edge of the area after Kelvin Langmead had sliced Mark Marshall's cross.
Arron Davies equalised for the Cobblers when he tapped in after Adebayo Akinfenwa had flicked on a high ball.
But Tozer grabbed the dramatic decisive goal, blasting home following more impressive hold-up play from Akinfenwa.
VIEWS FROM THE DRESSING ROOM
Barnet boss Lawrie Sanchez told BBC London 94.9:
"I was pleased with the performance as we played better than we have in recent weeks.
"We needed the second goal, and it doesn't come and I feel we were mugged, it was the most disappointing result since I've been Barnet manager.
"It was a sucker punch to lose a late goal but defensively it's not good enough."
Northampton Town manager Gary Johnson told BBC Radio Northampton:
"We like to play our proper game and win games but we weren't very good in the first half. We had to tell a few home truths at half-time and we had to up it.
"I asked the lads to look at the faces of our supporters, who deserved a little bit more - win, lose or draw.
"We are getting better and we're getting the luck we didn't have earlier. We've had a good six or seven games and we're three points off the play-offs."