Russ Wilcox's York found themselves in the bottom two after failing to win in their previous seven league matches.
However, Wes Fletcher opened the scoring in the 20th minute when his bending shot found the bottom corner and the striker added a second just before the hour to lift York to 20th, while Tranmere sit just one point above the drop zone.
Cheltenham parted company with Paul Buckle on Friday after less than three months in charge, but the move failed to have the desired effect as a 2-1 defeat to Bury saw them slip into the relegation zone.
Goals from Danny Mayor and Danny Rose put Bury into a 2-0 lead after just 17 minutes at the The Abbey Business Stadium and, although Denny Johnstone pulled a goal back, that was enough for play-off hopefuls Bury to take all three points.
Shrewsbury Town remain top of the table as goals from Liam Lawrence and Scott Vernon proved enough for a 2-0 victory over AFC Wimbledon, while Burton Albion stay level on points in second after winning by the same scoreline against Oxford United.
Third-placed Wycombe Wanderers lost at home for the second time in five days, a brace from Yan Klukowski earning Newport County a 2-1 triumph.
Luton Town are now just one point adrift of Wycombe after beating lowly Carlisle United 1-0, but Southend United failed to capitalise as they were beaten 2-1 by Accrington Stanley.
Northampton Town encouraged supporters to don wigs and masks to mark John Joe O'Toole day, but the cult midfielder's day ended in disappointment as he was sent off in the club's 1-1 draw at relegation-threatened Mansfield Town.
Elsewhere, rock-bottom Hartlepool United lost at home for the first time in 2015 in a 3-1 reverse to Stevenage, Plymouth Argyle beat Cambridge United 2-0 and Portsmouth were 1-0 winners over Exeter City.
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1