Referee Darren Drysdale gave the visitors a hotly-contested penalty after 32 minutes which Ryan Bowman tucked away.
The Stags felt they should have had two penalties of their own and York reduced to 10 men, but nothing went the hosts' way.
In stoppage time Drysdale then gave York a second penalty after his assistant had flagged for handball but goalkeeper Alan Marriott thwarted Wes Fletcher from 12 yards.
The first half erupted into anger after 32 minutes when Drysdale decided John Dempster had brought down Josh Carson in the box after he had got away from Jamie McGuire.
Despite the home side's prolonged protests, Bowman kept his cool to slot home low inside the right post.
Another flashpoint followed four minutes later as Dempster went down holding his head, with team-mates claiming Bowman had elbowed him, but nothing was given.
Stags thought they should have had a penalty when Keith Lowe's outstretched arm stopped McGuire's high ball into the box, before Matt Rhead then had his shirt pulled at a free-kick but again no spot-kick was forthcoming.
As the Stags piled on the pressure York almost sneaked a second goal on a counter, Michael Coulson firing just over the angle.
Then in stoppage time York were given another penalty for handball, this time Marriott denying Fletcher with his knees.