The principal goal of the American-led campaign here is to prepare an Afghan state and army to fight the Taliban themselves. The possibility of collusion between the Taliban and Afghan officials suggests that, rather than fighting each another, the two Afghan sides may often cooperate under the noses of their wealthy benefactors.

“People think the insurgency and the government are separate, and that is just not always the case,” another NATO official in Kabul said. “What we are finding is that they are often bound up together.”

The security companies, which appear to operate under little supervision, have sometimes wreaked havoc on Afghan civilians. Some of the private security companies have been known to attack villages on routes where convoys have come under fire, Western officials here say.

Records show there are 52 government-registered security companies, with 24,000 gunmen, most of them Afghans. But many, if not most, of the security companies are not registered at all, do not advertise themselves and do not necessarily restrain their gunmen with training or rules of engagement. Some appear to be little more than gangs with guns.

In the city of Kandahar alone, at least 23 armed groups — ostensibly security companies not registered with the government — are operating under virtually no government control, Western and Afghan officials said. On Kandahar’s chaotic streets, armed men can often be seen roaming about without any uniforms or identification.

“There are thousands of people that have been paid by both civilian and military organizations to escort their convoys, and they all pose a problem,” said Hanif Atmar, the Afghan interior minister. (Mr. Atmar resigned under pressure from President Karzai on Sunday.) “The Afghan people are not ready to accept the private companies’ providing public security.”

Many of the gunmen are escorting convoys carrying supplies to American and NATO bases, under a $2.2 billion American contract called Host Nation Trucking. American officials award contracts to Afghan and American trucking companies to transport food and other supplies to their bases around the country. They leave it to the trucking companies to protect themselves.