The Iraqi authorities have increasingly showcased Islamic State detainees to the public, as part of a strategy to demonstrate that the government is making progress in the fight, although they have not typically made detainees available for interviews with journalists. The details of Usaid’s personal background could not be independently verified, but his surrender at the mosque gate was captured on cellphone video by a bystander.

First, after the Islamic State took control of his town, Usaid was drawn to the local mosque. “We started being taught that Shiites were raping Sunni women, and that Shiites were killing Sunni men,” he said.

He now says he was brainwashed. But he admitted that he willingly ran away from home one morning on his way to school and joined a training camp in the desert. For about a month, he was put through military training, and he was taught how to shoot an assault rifle and how to storm a building. He had two meals a day, mostly cheese and eggs.

Soon, though, he said, “I noticed things I saw that were different from Islam.”

Back home he saw the group inflict severe punishments on men who were caught smoking cigarettes, yet in the camp, he said, he saw fighters smoking. He said he saw men having sex with other men behind the tents in the desert night. And, he said, he was increasingly put off by “the way they are killing innocent people.”

At the end of the training, he was told his trainers wanted him to go fight in Iraq. He was driven, with other new fighters, in a minibus to Mosul.

There, the recruits were given a choice: be a fighter or a suicide bomber.

“I raised my hand to be a suicide bomber,” he said. That, he figured, would give him the best chance at defecting.