JALALABAD, Afghanistan // In a remote corner of eastern Afghanistan the education system has been working well for years now — a rare success story amid the violence and political instability plaguing much of the surrounding countryside.

The situation in the Bati Kot district of Nangarhar province is particularly striking because the state schools there are controlled by the Taliban with government consent. It has been this way for much of the past decade, with the insurgents exerting control over the curriculum and officials happy to turn a blind eye to their strict interpretation of Islam.

In a country where the UN estimates that less than 50 per cent of the population aged 15 and older are literate, the deal between the two warring sides has benefited hundreds of children, local teachers told The National.

“Ordinary people and students are happy with both the government and the Taliban. From an education point of view, there are no problems now,” said Shaista Rahman Hanafi, a teacher in his mid-30s.

Bati Kot lies to the south-east of Nangarhar’s provincial capital, Jalalabad, close to Afghanistan’s border with Pakistan. Once the site of an ambitious Soviet agricultural project to turn vast areas of scrubland into olive and orange groves, the district’s population is overwhelmingly Pashtun. Olives, wheat, sweetcorn and water melons are among the crops grown there now.

The Taliban had significant influence in Bati Kot even when the US-led occupation was at its height in 2010. This allowed the insurgents to operate openly and they have proved surprisingly flexible when it comes to the education system, ensuring they continue to receive support from the sympathetic local population.

The government’s official curriculum is implemented in the district’s eight state high schools, with the Taliban outlawing only the teaching of culture and art. For the past four years these subjects have been replaced by lessons based on a Pashto book about the five pillars of Islam, which are taught by the schools’ religious studies teachers.

“Their educated men came to us and told us politely and respectfully not to teach these subjects,” said Mr Hanafi.

The Taliban regime that controlled most of Afghanistan between 1996 and 2001 was notorious for its hardline interpretation of Islam, which prohibited women from attending university and prevented girls from receiving all but a basic primary education. Boys were required to wear a simple Islamic hat up to sixth grade and a turban from sixth to twelfth grade.

Each school day began with a kind of religious song that is unaccompanied by music. The curriculum was leftover from the previous Islamist mujaheddin government, with the teaching of two more religious books added by the Taliban.

Even then, however, some Taliban officials at a local level adopted a more relaxed approach similar to the one now in place in Bati Kot.

Safiullah Sadiq, another teacher in Bati Kot, said the decision not to teach certain subjects has been tacitly approved by the Afghan government, which ordinarily sets the curriculum for state schools.

It continues to pay all the teachers’ salaries and is widely considered to regard the deal with the Taliban as a compromise worth making to allow children an education.

Mr Sadiq explained that teachers submit the scores students receive in their exams on the five pillars of Islam, as their official marks on their art and culture papers. The government accepts the results, no questions asked.

His school in the village of Nowaglo is a rudimentary building with a yard shaded by trees. It has 36 teachers, all of them male, for hundreds of students. Girls are taught separately up to the seventh grade while the boys study up to twelfth grade, but three other high schools in Bati Kot accept female students to higher classes on the condition they wear hijabs.

Mr Sadiq said the Taliban carry out regular inspections of most of the schools, checking the children’s hairstyles and clothing and the contents of their mobile phones to ensure they conform to their view of Islam.

The insurgent in charge of local education in Bati Kot is a young scholar named Mustafa. He works independently of the group’s fighters and assures teachers he will help them should any armed Taliban try to intimidate them. He is “very good with us”, said Mr Sadiq.

Arrangements like the one in Bati Kot are not uncommon in Afghanistan. While schools were often attacked in the early years of the war, the Taliban has adopted a more conciliatory approach nationally since about late 2010.

Past reports by the Kabul-based Afghanistan Analysts Network attributed the change to pressure from local communities but said regular talks have also taken place between the ministry of education and the Taliban.

However, deteriorating security is beginning to complicate matters in Nangarhar. The Taliban’s hold on Bati Kot has been contested by ISIL and the education system in other parts of the province is suffering badly because of the violence that has accompanied ISIL’s rise.

A 43-year-old teacher in the district of Deh Bala told The National the Taliban began to negotiate with teachers there in 2010 but only enforced their rules on schools in 2012, when they banned the teaching of culture and mathematics.

He said the insurgents had initially been “very gentle and nice with us”. They told teachers they must arrive at school by 8am and leave at exactly 12pm. Teachers absent without a valid excuse were required to pay a fine taken from their salary.

But as the Taliban military strength grew their attitude began to change and they “killed some people who were not obeying them”, he said. The situation deteriorated further when ISIL drove the Taliban from parts of Deh Bala. Twenty-four schools in the district are now shut, open in name only, he said.

The teacher has lived in Jalalabad for the past two years. He travels regularly to Deh Bala to check on an agricultural institute he helps run from a rented house after its original building was taken over by ISIL.

The journey is fraught with danger, as demonstrated when an off-duty policeman was murdered while going to the district to visit his family.

“When they killed him they dropped his uniform on top of his dead body, to show this was the reason for his punishment,” said the teacher.

* Chris Sands contributed to this story from the UK