Luke Norris fired home an injury-time free-kick as League Two's bottom club Northampton ended Fleetwood's run of four successive wins.
The hosts were on top in the first half but Fleetwood's David Ball went closest when he hit the post from 12 yards.
Ball went off injured before the break and his replacement Jon Parkin made a clumsy challenge in the 90th minute to give the Cobblers a late chance to win.
And Norris curled over the wall to grab a first league victory in five games.
But Northampton remain bottom of the standings, while Fleetwood drop from top to fourth.
VIEW FROM THE DRESSING ROOM:
Northampton Town manager Aidy Boothroyd tells BBC Radio Northampton:
"I've seen Fleetwood a couple of times and they're top of the league for a reason.
"But I thought our work ethic and willingness to want to get out of the trouble we're in was fantastic today. I'm really, really pleased.
"We deserved what we got. We played very, very well. I'm delighted for our supporters because we haven't had many wins like that.
"We've beaten the top of the league now, so there's no more excuses."
Northampton Town 01 Duke 12 Tozer 03 Widdowson 32 Ferdinand 18 Reid 27 Kouo-Doumbe Booked 11 Hackett (Dallas - 45' ) 34 Ravenhill 25 Blyth 33 Norris (Morris - 92' ) 19 Emerton (Demontagnac - 65' ) Substitutes 04 Carter 07 Demontagnac 08 Morris 16 Hooper 17 Deegan 21 McNamara 29 Dallas Fleetwood Town 01 Davies 15 McLaughlin Booked 20 Taylor 08 Schumacher 06 Pond 16 Cresswell 07 Evans (Brown - 76' ) 04 Murdoch (Blair - 56' ) 23 Ball (Parkin - 34' Booked ) 18 Sarcevic Booked 11 Hughes Substitutes 05 Roberts 09 Parkin 12 Brown 14 Hogan 17 Blair 29 Dieseruvwe 33 Lucas
Ref: Garry Sutton