Every morning in this mountain village in eastern Afghanistan, four dozen girls sneak through a square opening in a mud-baked wall, defying a Taliban edict.

A U.S.-funded girls school about a mile away was shuttered by insurgents in 2007, two years after it opened. They warned residents that despite a new government in Kabul and an international aid effort focused on female education, the daughters of Spina were to stay home. For a while, they all did.

Then two brothers, among the few literate men in the village, began quietly teaching math, reading and writing to their female relatives in a living room on the edge of town. They wanted to keep the classes small, they said, to stay off the Taliban’s radar. That turned out to be impossible.

The United States and its allies have spent millions of dollars on female education in the past decade, and Afghan and Western officials have pointed to the issue as one of the most hopeful changes of the post-Taliban era. Female enrollment in public schools has risen from 5,000 under the Taliban to 2.5 million, according to the Afghan Education Ministry.

But Afghanistan is rife with places like Spina, where formal efforts to educate women and girls have crumbled. About 2 million Afghan girls do not attend school.

Those who do sometimes face threats. Last week, suspected militants poisoned more than 100 schoolgirls in northern Afghanistan, according to Amanullah Iman, a spokesman for the Education Ministry, who said an investigation into the incident was ongoing. The girls are recovering.

Because of threats, several schools in eastern Afghanistan have been closed in the past few months, reversing what had been a positive trend, said Vidhya Ganesh, the deputy country representative for UNICEF.

The insurgency had already forced the closure of dozens of girls schools beginning in the middle of past decade, when insurgents started to return to Afghanistan. Many of the schools were built and funded by the United States, and many never reopened. In some villages, the schools have gone underground, hidden in living rooms and guesthouses, as they were during the Taliban’s reign.

“It’s risky for the teachers and it’s risky for the students, but these underground schools show the thirst people have for education under the Taliban,” said Shukriya Barakzai, a parliamentarian who ran her own underground school when the Taliban held power in Kabul in the 1990s.

“It doesn’t feel much different from those years,” said one of the brothers in insurgent-infested Spina. “We live in a community very far from democracy and freedom.”

‘Something from nothing’

When the insurgency arrived in this patch of Paktika province in 2005, it did so with great force and little resistance. The absence of Afghan or American security forces meant fighters could wield weapons freely and threaten residents without consequence. The warning to girls went unchallenged.

But word soon spread about the underground girls school — part of a shadow education system developed in places such as Spina to elude the Taliban. The full extent of the system is not known, but American and Afghan officials say such underground networks are not uncommon in places with a large insurgent presence.

First, young students — between 5 and 12 years old — would trickle into the home of the two brothers, who for security reasons insisted that their names not be published. Then, teenagers started arriving, the brothers said, a particularly rare and controversial development in eastern Afghanistan, where females are expected to remain home upon reaching adolescence.

The brothers could hardly believe the turnout, which at once worried and excited them. They named the school after their great uncle, Namizad, a religious scholar.

“The girls just kept coming.” one brother said. “They were so eager, like they were starving.”

When a U.S. army platoon made a rare visit to Spina this month, soldiers saw the school as an example of resilience in the face of a failed development project, a sign of hope in a dismal place. In recent months, according to U.S. officials, the Taliban in Paktika have robbed teachers of their salaries to buy an 82mm mortar and shells.

“I want to thank you for your courage,” U.S. Army Lt. Col. Curtis Taylor told the brothers and their students after ducking through the family’s living room doorway.

The girls at the Namizad School sit on carpets, beginning each class with a recitation from the Koran. A chalkboard rests on the floor. Less than half the class has textbooks, which have made their way from Kabul. As in the rest of Spina, there is no electricity.

“These students are learning something from nothing,” one of the brothers said.

The brothers have pleaded for more resources. They have prayed to remain outside the Taliban’s reach. But the district’s education director claimed he had no money for the education of girls, the brothers said, in an account confirmed by local officials. And the Taliban have crept ever closer.

A few months ago, insurgents posted a letter on the brothers’ door. “We will not allow the education of girls,” it read, calling the practice “un-Islamic.” The letter warned of a violent punishment.

The brothers talked about what to do. Should they end the classes? Should they leave Spina?

The two willowy men in their early 30s have bright eyes and long brown beards and wear flowing white salwar-kameez, the traditional dress here. Their backgrounds are strikingly similar to those of the insurgents who threaten them. Like the Talibs of western Paktika, the brothers were educated in Pakistani madrassas, or religious schools. They, too, were raised to believe in a strict adherence to the Koran, Islam’s holiest book.

“I was so close to joining the Taliban,” one said. “The men haunting us, they are men we know well.”

‘I want to learn everything’

The brothers tried to make the case to the Taliban that they would teach only religious material to their students. They warned their students of the risk of attending classes, and they were surprised again when the girls kept coming. There’s now a morning class for young children and an afternoon class for teenagers. The brothers beam when talking about recent graduates, eight of whom are now trained midwives.

“I liked the other school better. We had desks and books,” said Baranah, 11, who was in first grade when the Taliban closed the U.S.-funded school. “But this place is still good. We still learn here. I want to learn everything.”

The insurgency has not followed through with its threat. The brothers wonder if it ever will — if the Taliban’s recent silence signifies its tacit approval or is merely a prelude to violence.

In some cases, the Afghan government and international organizations have been able to reach compromises with insurgents to keep schools open.

“We’re beginning to find ways to negotiate with anti-government elements,” said UNICEF’s Ganesh.

Some here worry that women’s rights are being sidelined as the United States prepares to leave and the Afghan government attempts to satisfy a hard-line constituency. In March, top religious leaders on the country’s Ulema Council ruled that men are “fundamental” and women “secondary,” barring women from interacting with their male counterparts in schools or the workplace.

In Spina, only boys are educated in the U.S.-funded, one-story yellow building constructed five years ago to educate girls. Most of the windows are broken, and the paint is chipping.

“That place seemed perfect,” one brother said. “But we knew it wouldn’t last long.”