York ended a run of two games without a victory with a 1-0 National League win from the long trip to Yeovil to keep their promotion charge on track.
Josh Stones came closest to breaking the deadlock in the first half with 37 minutes on the clock after driving forward and cutting inside onto his left foot, but an organised Glovers defence blocked the effort.
Brett McGavin fired narrowly over for the hosts after the restart before City were awarded a penalty in the 56th minute when Joe Felix was brought down in the box.
Ollie Pearce kept his nerve from the spot to stroke home his 23rd goal of the season and York were then largely untroubled to hold on for the points.
Subscribe or register today to discover more from DonegalLive.ie
Buy the e-paper of the Donegal Democrat, Donegal People's Press, Donegal Post and Inish Times here for instant access to Donegal's premier news titles.
Keep up with the latest news from Donegal with our daily newsletter featuring the most important stories of the day delivered to your inbox every evening at 5pm.