Chris Beardsley crowned his full Mansfield debut with his first goal to clinch Mansfield's fourth successive victory and leave York without a goal in their last five away games.
Beardsley flicked in Dave Artell's powerful header from a Liam Lawrence corner 14 minutes from time to make amends for missing two clear chances.
Afterwards a delighted Beardsley said: "I'm just pleased to be getting the chances to score. I am still young and will have to wait for my chance, but I just want to stay in and around the team." His delighted manager Keith Curle added: "Chris has been on the fringes since I came to the club, but he always wants to learn and wants to score. Hopefully, that's the start of his career." York, who had almost equalised through Mitch Ward's long-range blockbuster in the 63rd minute, were again unlucky in the 83rd minute when substitute John Parkin rattled the bar with a dipping half-volley.
But Mansfield, who clinched their best sequence of results for nine years, dominated throughout and only the acrobatics of City keeper Mark Ovendale denied Colin Larkin and substitute Lee Williamson further second-half goals.
Afterwards, York's player-manager Chris Brass said: "We were beaten by a better side who had more quality in the final third. We need to learn and learn quickly." York had given a debut to on-loan Middlesbrough midfielder Craig Dove in a bid to end their away day goals drought, but all the early chances fell to Mansfield.
First Larkin hooked wide from an acute angle after he seized on a misplaced Brass header, then in the 11th minute, Artell's goalbound header from a Lawrence corner created mayhem in the York area before Ovendale saved on the line.
Three minutes later, the keeper dived full length to beat away Larkin's drive and moments later Beardsley headed wide from a deep Wayne Corden cross.
York finally posed an attacking threat midway through the half, Ward's explosive long-range drive tipped around the post by the diving Kevin Pilkington. Then the tricky Dean Crowe's shot brushed the outside of the post.
Mansfield hit back to take the lead in the 31st minute. This time Ovendale failed to hold the ball in the area and Artell reacted the quickest to tap in the breakthrough.
Ovendale redeemed himself with another splendid save two minutes before half time, first diving to block Corden's long-range curler and then reacting the quickest to deny Beardsley from the rebound.