Geoffrey D. Langlands, a British officer who stayed in Pakistan after his military service ended and became one of the country’s most celebrated educators, died on Wednesday at a hospital in Lahore. He was 101.
Aitchison College, Pakistan’s most prestigious boarding school, where Mr. Langlands spent 25 years as a teacher and later a headmaster, said in a statement that he had died after “a brief illness.”
In more than six decades of teaching mathematics and English, sometimes in regions rife with violence, Mr. Langlands, commonly known as “The Major,” guided the children of Pakistan’s elite to top careers. His students included Zafarullah Khan Jamali, a former prime minister, and Imran Khan, the current prime minister, who said on Twitter that he was “saddened” by his teacher’s death.
“He stood out,” Mr. Khan said of Mr. Langlands in 2012. “He had this mixture of being firm yet compassionate.”
Mr. Langlands and his twin brother, John Alexander Langlands, were born in Yorkshire, England, in 1917. His father died in the worldwide flu epidemic of 1918, and his mother, a folk dancer, died of cancer in 1930. His grandparents assumed custody, only for his grandfather to die a year later.
Mr. Langlands taught science and mathematics in London before enlisting in the British Army in 1939 as World War II began. He fought in a commando unit, battling the Germans in France.
In 1944, he joined the British Indian Army and was posted in Bangalore, put in charge of recruiting and training young officers. He survived an attack by Muslim gunmen while on a train with Hindu refugees in 1947.
Mr. Langlands then spent six years as an instructor in the Pakistani Army. Mohammad Ayub Khan, who became Pakistan’s president in 1958, asked him to stay in the country, and he accepted a job teaching algebra at Aitchison College in Lahore.
In 1979, Mr. Langlands moved to the region of North Waziristan to become the principal at Cadet College Razmak, a military high school. In 1988, tribesmen there held him hostage for six days.
“It wasn’t so bad,” he said in 2012. “They were very polite once they found out I was 71. And before I left, they insisted on having their photo taken with me.”
A year later, he moved to Chitral and became the headmaster of Sayurj Public School, which would later be renamed for him as Langlands School and College. He taught there until 2012, when he was 94, and was considered a key member of the community.
“The major is invaluable,” Sultan Mehmood, a local development worker, said in 2012. “We cannot replace him.”
Mr. Langlands lived in a small cottage and paid himself a paltry salary. His servant appeared each morning with the exact same breakfast: oatmeal, a poached egg and two cups of tea. He kept photos of his famous visitors, including Diana, Princess of Wales, who came to Chitral in 1991.
Mr. Langlands never married. In his final years, he lived in an apartment that his former students arranged for him on the grounds of Aitchison College.