SALANG, Afghanistan — There is not an ounce of fat on the wiry frame of Abdul Wahid, and no wonder.

After he finishes his morning work shift, he walks 10 miles down mountain trails in northern Afghanistan to the first road, where he catches a bus for the last couple of miles to the teacher training institute in Salang. He walks back up the mountain another 10 miles to get home, arriving well after dark, just in time to rest up for his day job.

In his determination to formally qualify as a teacher, Mr. Wahid, 33, exemplifies many of the gains for Afghan education in recent years. “It’s worth it, because this is my future,” he said.

But he also personifies how far the efforts here have yet to go. Mr. Wahid’s day job is being the principal of the high school in his village, Unamak. Though he has only a high school diploma, he is the best educated teacher that his 800 students have.

It is widely accepted that demand among Afghans for better schooling — and the actual opportunity to attend, particularly for girls — is at its highest point in decades. For Western officials seeking to show a positive legacy from a dozen years of war and heavy investment in Afghanistan, improvements in education have provided welcome news.