SHEBERGHAN, Afghanistan — The top commander of the Islamic State in northern Afghanistan stood behind a lectern decorated with the shield of the Afghan government’s powerful intelligence agency.
On his left was the police general in charge of the province. Arrayed behind him was an assortment of other dignitaries: police, army, political figures. An attendant put a bottle of mineral water nearby, in case the intense heat made the commander thirsty.
This is how the Islamic State commander, Maulavi Habib ul-Rahman, began his “imprisonment” on Thursday. Along with 250 of his fighters, Mr. Rahman had surrendered the day before to the Afghan government in the northern province of Jowzjan, to avoid being captured by the Taliban.
He thanked his hosts and, in a scolding tone, warned them to stick to the deal they had just made. “Provide us with personal security as well as stay loyal to the commitments made between us so it prepares the ground for others who fight against the government to join the peace process,” Mr. Rahman demanded from the dais.
Peace process? Officially, Mr. Rahman, another Islamic State commander, hundreds of fighters and 20 relatives traveling with them were prisoners who had turned themselves in to the government to avoid imminent capture by Taliban insurgents who had conducted a monthlong offensiveagainst them.
Other insurgents have joined the government side through a formal peace process open to those not accused of human rights abuses, but that is not a possibility with the Islamic State, officials insisted.
“They surrendered to Afghan forces — they did not join the peace process. These are two different things,” said Gen. Faqir Mohammad Jawzjani, the provincial police chief, who shared the podium with Mr. Rahman.
If they were prisoners, however, it was hard to tell. The government arranged for them to stay in a guesthouse in the provincial capital of Sheberghan. Guards were posted around it not to keep the insurgents in, but to keep their potential enemies out, according to the provincial governor. Although the fighters were disarmed, they were allowed to keep their cellphones and other personal possessions.
In the guesthouse, the Islamic State fighters celebrated their good fortune, hugging and slapping one another on the back. One of their commanders, Mufti Nemat, wearing in a pink shalwar kameez and a knockoff of an Apple watch and holding a satellite phone, fielded calls steadily between giving interviews.
Some of the police officers were angry. “Why didn’t we just let the Taliban kill them, instead of treating them like honored guests?” one officer said.
At their peak, the ISIS fighters in northern Afghanistan numbered as many as 500 followers of Qari Hekmatullah, until he was killed in an American airstrike in April. Mr. Rahman and Mr. Nemat, who are brothers-in-law, then emerged as the leaders of the group.
Mr. Nemat bemoaned what he described as a “fake news” climate around their decision to go over to the government side. “We believe that the U.S. supports the Taliban,” he said. “Everyone is against us. Every side puts pressure on us: the Afghan government, the Taliban and also the people. The whole world is against us.”
Mr. Nemat said he joined the Islamic State because he believed in the group’s ideology, which he felt was closer to Afghan values than that of the Taliban or the government. Mr. Nemat, Mr. Rahman and their followers previously fought on the side of the Taliban and the government before joining the Islamic State in 2016.
“We want other people to accept our ideas with their hearts, not by force,” Mr. Nemat said. “There is no need to force people to accept us.”
The dubious nature of the Islamic State surrender has proved a propaganda bonanza for the Taliban, which began an offensive with thousands of fighters about a month ago to wipe out the Islamic State group in the north. All of their fighters have now surrendered, been captured by the Taliban or been killed, according to Mr. Nemat, as well as government and Taliban spokesmen.
Much was made by the Taliban and by the government’s critics here of the mode of the Islamic State prisoners’ arrival in Sheberghan. They were ferried from the battlefield in Afghan Army helicopters, avoiding a potentially dangerous journey on the roads.
Mr. Nemat, was nervously defiant, saying: “The Afghan government promised they wouldn’t punish us. The Afghan government must save my life and provide me with security.” He insisted his commanders and their followers were guilty of nothing other than fighting on the battlefield. “I am ready to go to court if there is any proof against me,” he said.
Lines had already started forming outside the provincial police headquarters, with people offering such proof. General Jawzjani said 50 complaints had been received by Thursday: “On every complaint, the fighters will be questioned and investigated.”
The complainants included Yar Mohammad, 53, a farmer from the Darzab district of Jowzjan Province, where the Islamic State fighters had their stronghold in the north. On July 24, he said, his pregnant niece, Noria, was shot to death by Mr. Rahman and Mr. Nemat’s group of fighters while she was visiting the doctor. Five months earlier, his cousin Barakatullah was beheaded by them on suspicion of supporting the government.
“ISIS fighters killed more than 100 people in Darzab,” Mr. Mohammad said. “The government has to prosecute these killers.” The Islamic State is more commonly known in Afghanistan as ISIS or Daesh.
After watching television footage of the prisoners being fed rice pilaf with meat and vegetables and bottled water, Abdul Hamid, 52, was infuriated. Along with some 10,000 other people over the past two years, he had fled Darzab to a squalid life as a displaced person in Sheberghan, where meat is an unimaginable luxury.
“We lost everything to Daesh, and now the government sends helicopters for them from Kabul and brings them here and gives them rice and meat and mineral water, and provides them with security, and we are not even able to find food,” he railed.
The governor of the province, Lutfullah Azizi, said any crimes would not be overlooked. “We welcome them if they accept Afghan law,” he said. “But those who committed crimes, if there is any documentation or proven complaint against them, they will be punished.” He added that “hundreds” of complaints had been lodged against them during their years in power.
Many of the Islamic State’s crimes are well documented in their own Facebook and WhatsApp posts, with videos of them burning opponents alive, stoning people to death, training children as fighters, and shooting bound prisoners.
They also took credit previously for the killings of six workers from the International Committee for the Red Cross last year, an atrocity that was part of the reason the Red Cross has suspended much of its operations in northern Afghanistan.
On April 15, “they beheaded a 12-year-old child on an allegation of cooperating with local police,” said Baz Mohammad Dawar, 32, also a refugee from Darzab. “They committed hundreds of crimes including raping women and girls, enslaving women, killing and beheading.
“People will not let this go. They killed too many of their sons, and stole so much of their livestock, there will be huge protests if the government does not punish them.”
The Islamic State still has a major pocket of fighters in the southern part of Nangarhar Province, in eastern Afghanistan, but concerted attacks on them by American and Afghan special forces, backed up by airstrikes, have greatly reduced their presence in that area. In recent months, they have concentrated instead on launching suicide attacks on lightly defended civilian targets.
An official with the National Directorate of Security, the powerful intelligence agency, said the Islamic State group would be in for a surprise once they were transferred to the custody of the N.D.S. in Kabul.
“We don’t do peace with ISIS,” he said. “ISIS is an international terror group. We don’t make peace with terrorists.”