Town had began on top at the PTS but Mansfield struck against the run of play when Mal Benning’s corner somehow evaded defenders and attackers alike to find its way into the net.
But in a game devoid of chances, Town levelled with 21 minutes to go as Foley headed in a pinpoint corner from young Scott Pollock, who impressed throughout on his full debut, to hand the home side a deserved point, though the Cobblers did drop a place to 15th in Sky Bet League Two.
Manager Keith Curle sprung a few surprise selections for the visit of high-flying Mansfield. Jack Bridge and Ash Taylor dropped out of the squad altogether, as did Marvin Sordell, and in came teenager Pollock for his first Cobblers start.
Shay Facey was drafted back into the side, his first start since early February, Andy Williams led the line alongside Daniel Powell and there was a long-awaited return to the squad for Brighton loanee George Cox.
Curle also tweaked the system, going back to 3-5-2 with Jordan Turnbull in defence, and his team made the brighter start, Aaron Pierre heading David Buchanan’s free-kick into the side-netting on just four minutes.
Ryan Sweeney almost diverted Sam Hoskins’ cross into his own net as Mansfield struggled to get beyond halfway in a first 11 minutes dominated by the Cobblers.
But, not for the first time this season, failure to turn pressure into goals was followed by some haphazard Northampton defending at the other end, with the Stags scoring from their first real attack on 12 minutes when David Cornell misjudged Benning’s corner and the ball went all the way in.
Hoskins had a shot blocked for the Cobblers and an unmarked Turnbull couldn’t make the most of an opportunity from Pollock’s deep corner.
The 18-year-old was catching the eye in central midfield but the home side had little else to shout about in a first-half that was desperately short on goalmouth incident.
Benning’s freak goal was still the difference at half-time and that remained so into the second-half when Town got nowhere in their efforts to get back into the game as Mansfield’s Conrad Logan continued to be a spectator in the away goal.
But the hosts were back on level terms with a goal out of nothing midway through the half, Foley timing his run and jump to perfection in heading home Pollock’s excellent corner.
That stung Mansfield back into life as Danny Rose headed wide from a corner although the visitors were not able to seriously test Cornell.
Rose should have at least made Town’s goalkeeper work with five minutes to go when lofting over the crossbar from eight yards.
Junior Morias and Cox were both sent on by Curle in the final 10 minutes but it was the visitors likelier to win it with Jacob Mellis’ stoppage-time free-kick flying over in a last-gasp chance to snatch all three points.
Cobblers: Cornell, Facey, Goode, Pierre (c), Buchanan (Cox 89), Turnbull, Foley, Pollock, Hoskins, D Powell (Morias 82), A Williams
Subs not used: Coddington, O’Toole, Bowditch, Elsnik, J Powell
Mansfield: Logan, Benning, Preston, Pearce (c), Bishp, MacDonald, Tomlinson (Mellis 56), Sweeney, Walker, Jones (Rose 65), CJ Hamilton
Subs not used: Smith, Atkinson, Grant, Law, Hakeem
Referee: Paul Marsden