When the operative asked if the two Taliban had government IDs, they pulled them out, neatly wrapped in plastic sheets. Asked how they had obtained the documents, one of the men, who gave his name as Zabihullah Ghorzang, replied:

“My uncle was the district governor here.”

Putting his hand on Mr. Ghorzang’s knee, the operative said the men’s decision to join the government’s side was patriotic. The government had forgiven their wrongdoings. The deal complete, Mr. Ghorzang was given back his pistol.

But Mr. Makee, who was at the meeting, couldn’t keep quiet. “The government can forgive you for all it wants,” he told the two Taliban. “But if I find out that you had done anything wrong against my men, I swear I will chase you wherever you hide.”

Lt. Col. Noor Agha, the third of the three men fighting ISIS here, is a district police chief who cuts a soft-spoken, fatherly figure. He has been in charge of the last line of defense against ISIS: This far into Taliban country, there were no Afghan commandos or American special forces to help out.

Colonel Agha has only about 170 regular police officers under his command, 30 of them not present for duty, and about as many militiamen, such as the ones Mr. Makee commands.

As residents started fleeing last month from the fighting between the Islamic State and the Taliban, it suddenly appeared that the government could lose even its nominal control if ISIS fighters reached a strategic hill.

Colonel Agha carved a road from the district center to the top of the hill, a path made for the first time, 16 years into the war. He cobbled together about 50 men, 20 of them from the army, and they made their way through the poppy fields to establish outposts on the hill.

Many of the men on the hill slept under the open sky. They lacked heavy weaponry. As they looked down, it was Taliban to the right, Taliban to the left, Taliban at the foot of the hill. In the distance was the Islamic State, its fighters heavily armed with machine guns and rocket launchers, Col. Agha says. He knows that because his troops have been fired upon and taunted over the radio as infidels and American militias.