KABUL — Rahmatullah Andar was once a feared Taliban commander, locked in bloody skirmishes against American and Afghan government troops in the rugged landscape of eastern Afghanistan.
In 2007, an American Special Operations team captured him during a night raid on a house in his ancestral village in Ghazni Province. He spent two years in an American-run prison at Bagram Air Base outside Kabul.
Today, Commander Andar is Spokesman Andar — the official spokesman for the National Security Council of the American-backed government of Afghanistan. The story of how a former Talib became a high-ranking government security official is also a chronicle of the endless Afghan war itself: Allegiances shift. Enemies become allies. The players change roles, but the war endures.
The 19-year-old conflict is as fiercely contested today as when Mr. Andar commanded Taliban fighters for several years, only to break with the militants and lead one of Afghanistan’s first local uprisings against the Taliban in 2012. He lost his father, 75, his brother, an uncle and two cousins — all killed by the Taliban out of revenge, he said.
Today Mr. Andar is a religious scholar with two master’s degrees who serves a government he once vowed to overthrow. And he remains a target of his former comrades in arms, who regard him as a turncoat.
“The Taliban intend to assassinate me,” Mr. Andar, 41, said during an interview inside the presidential palace complex in Kabul. “Whether I’m a member of the government or not, they will never leave me alive.”
Mr. Andar, alternating among Pashto, Farsi and English, was relaxed and voluble as he recounted a life spent on battlefields, on the run, in universities and in prisons. He is a consummate survivor.
He described withstanding Taliban kidnapping attempts and ambushes, interrogations by American captors, and two stints in Afghan government prisons — accounts born out by official records and by those who fought alongside him.
With his tangled beard and long hair, he might still be mistaken for a Talib, though he insists that he regards the militants with contempt — and hopes to serve as an example of how the insurgents hold no monopoly on Afghan piety.
He was appointed to his National Security Council position by President Ashraf Ghani on Sept. 25, in large part because of both his religious credentials — he has earned the religious honorific of Mawlawi, meaning Islamic scholar — and his reputation as a fighter against the Taliban.
His appointment was a clear statement from the Afghan government, as a central idea behind the Taliban’s criticism is that the government remains insufficiently Islamic, and is a puppet of the Americans.
A single appointment cannot polish the religious image of an entire government, Mr. Andar acknowledged. “But the government can show by its actions that the Islamic Republic of Afghanistan is more than just a name,” he said.
And he said the Taliban, by signing a troop withdrawal agreement with the United States in February while freezing out the Afghan government, had undercut its own claims of Islamic purity.
“They say government officials are infidels, but they have an agreement with the Americans, whose troops invaded Afghanistan,” he said. “So now they have no logic for this war” against fellow Afghans and Muslims.
The Taliban have said that any new government arising from negotiations with Afghan representatives in Doha, Qatar, must be based on Islamic principles. Some analysts have interpreted that to mean the same harsh Shariah law that was imposed when the Taliban governed Afghanistan in the late 1990s.
Mr. Andar said the Taliban could not change Afghanistan’s Constitution without the consent of a loya jirga, a traditional gathering where matters of national importance are debated. And Article 3 of the Constitution already stipulates that no law “can be contrary to the beliefs and rules of the holy religion of Islam,” he said.
Many Afghan women have expressed fears that a return to government by the Taliban would erase gains they have made since the militants were overthrown in 2001. The Taliban beat women, confined them to their homes and banned them from going to school.
Mr. Andar said those prohibitions were not properly rooted in Islam, as the religion does not forbid girls and women from attending school. In fact, he said, the closing of schools by the Taliban in his home district is what precipitated his split from the movement three years after his release from American custody.
“The Taliban closed the schools and opposed reconstruction, kidnapping and killing engineers,” said Amanullah Kamran, deputy of the provincial council in Ghazni. He said Mr. Andar, who supported women’s education and the U.S.-led reconstruction effort, took up arms against the Taliban and helped form one of the country’s first local uprisings against the insurgency.
Mr. Kamran said the fighting left nearly 500 Afghans dead in the district and another 500 wounded. Mr. Andar himself was wounded in battles that ultimately killed his closest male relatives, he said.
“Finally there was no man left in Rahmatullah’s family except Rahmatullah,” Mr. Kamran said.
Mr. Andar said he now cares for 21 children and widows. Asked whether he still carried an AK-47 rifle from his combat days, he laughed and said he had only a pistol for personal protection.
In recent months, the Taliban have mounted a series of targeted attacks against government officials and those perceived to be government supporters. But Mr. Andar explained his shifting allegiances by blaming both the government and the Taliban. He said he joined the Taliban after the government jailed him for two months in 2003 upon his return from religious studies in Pakistan.
“The government pushed me to the Taliban by its actions against me,” he said.
Years later, he said, he turned against the Taliban once the militants began closing schools and terrorizing the residents of his district — violations of Islamic strictures. “Even fighting has rules under Islam, and the Taliban broke those religious rules,” he said.
A Taliban spokesman, Zabihullah Mujahid, said Mr. Andar and his male relatives were legitimate targets because they had collaborated with Americans while commanding pro-government militias.
After the Taliban burned the homes of Mr. Andar and his relatives — torching his personal Quran and killing their livestock — Mr. Andar said he fled to Kabul. There, he earned a second master’s degree, in educational management, to supplement a previous master’s in Islamic studies. He later served as a religious adviser for the National Security Council.
In his current position, Mr. Andar encounters former enemies. Asadullah Khalid, the acting defense minister, was governor of Ghazni Province when Mr. Andar was arrested and jailed there.
“I see him in meetings now and he tells me he’s my friend. We respect each other,” Mr. Andar said.
The spokesman’s job also requires an alliance with American and Afghan military commanders. Asked whether his fighters had killed or wounded American and Afghan troops, Mr. Andar shrugged. “It was a war,” he said. “Of course there were casualties.”