Substitute Lee Hughes popped up in the 88th minute to snatch all three points for Notts County after what was an entertaining but ultimately heart breaking evening for Town at Meadow Lane.
The hosts made much the stronger start and might have gone in front as Craig Westcarr pounced on a weak back header from Lecsinel Jean-Francois and shot powerfully towards goal, but Phil Smith beat the ball away strongly with his right hand.
County were still on top but it was Town who went close next, with Michael Timlin finding space on the edge of the box and volleying right footed towards goal, but Jon Harley did well to block the goalbound effort.
Smith was called into action again after 15 minutes, stretching well to fingertip another Westcarr shot round the post as the hosts continued to look the stronger of the two sides.
Westcarr went close again moments later as he raced onto Lee Miller's flick on to volley just over the bar from the edge of the box.
While Lecsinel Jean-Francois might have presented Westcarr with a golden opportunity earlier in the half, he denied him brilliantly after 27 minutes, seemingly emerging from nowhere to nick the ball off his toes as the striker looked destined to give County the lead after being set clear by Ben Davies.
Town's best move of the game followed after 37 minutes, and might have seen them go in front had it not been for a sharp low save from Rob Burch after Matt Ritchie's cross had been slammed goalwards by David Prutton.
This signalled a strong end to the half for Town, as they forced a succession of late corners and throw-ins which almost resulted in an embarrassing own goal from Liam Chilvers as he awkwardly kneed a Sean Morrison back header narrowly over his own crossbar.
Despite a decent number of chances, the half came to an end with neither side able to break the deadlock.
County flew out of the blocks in the second half, and tested Phil Smith on two occasions, the 'keeper first beating away a Ricky Ravenhill volley before calmly collection a long-range effort from Craig Westcarr.
It was then Town's turn to go close, as a deep corner found Jonathan Douglas who looped the ball back across goal towards Charlie Austin, whose goalbound header was cleared off the line sharply by Liam Chilvers.
After a decent period of pressure for the visitors, it was the Magpies who were inches away from opening the scoring, as Ben Davies' 25-yard free-kick had the beating of Phil Smith, but passed just wide of the post.
As the match moved into its final 15 minutes, it was anyone's for the taking, but Jon-Paul McGovern's 30-yard volley which was collected by Burch remained the only test either 'keeper had had in what had become a scrappy final quarter of the clash.
However, just as Town looked to have earned another away point, substitute Lee Hughes notched an 88th minute winner, collecting a Craig Westcarr cross inside the box and rolling the ball past Phil Smith and into the corner.
The visitors inevitably rallied and might have equalised seconds later as David Prutton flew into the box to meet a Michael Rose cross, but the midfielder's header passed just wide of the near post.
An off-target Rose free-kick aside, this proved to be the last chance for Town to snatch a point, and they went down to a gutting defeat at Meadow Lane.