Dave Winfield gave the Minstermen an early lead at Field Mill but Krystian Pearce levelled for the hosts just past the half-hour mark and the visitors went on to survive a second-half onslaught that saw their goal frame and goalkeeper Scott Flinders severely tested.
York could not have got off to a better start when they forged ahead on 10 minutes with centre-back Winfield’s second goal in as many games.
The unmarked former Wycombe defender steered Luke Summerfield’s left-wing free kick into Brian Jensen’s bottom-left corner from eight yards.
But the Stags responded with a series of corners that led to a 31st-minute equaliser. Adam Chapman’s right-wing flag kick picked out Pearce eight yards from goal.
Mansfield made most of the running in the second half as they searched for only a fourth league win on their own turf this term.
Matt Green clipped the top of Flinders’s crossbar from six yards after charging on to Nathan Thomas’s low left-wing cross.
A 20-yard Reggie Lambe strike thudded against Flinders’s bar, before the goalkeeper thwarted substitute Adi Yussuf.
Mansfield: Jensen; Rose, Pearce, Collins, Adams; Lambe, Chapman, Clements, Blair (N Thomas, 56); Green, Westcarr (Yussuf, 78). Unused substitutes: Shearer, Beardsley, Tafazolli, J Thomas, McGuire.
York: Flinders; Nolan, Winfield, Boyle, Ilesanmi; Summerfield, Penn, Berrett; Galbraith, Oliver, Fewster (Carson, 77). Unused substitutes: Ingham, Straker, Swan, Godfrey, McEvoy, Kitching.
Referee: D Handley.
Man-of-the-match: Scott Flinders.