PESHAWAR, PAKISTAN, JAN. 9 -- The rush of talk about a Soviet troop withdrawal and early settlement of the war in Afghanistan has caught some participants by surprise, creating more uncertainty about the future of a country that already is one of the world's most chaotic.

After half a dozen governments and coups, invasion and civil war in the last two decades, Afghans of varied political and ethnic allegiances must weave through a minefield of mutual suspicions and hatreds that could prolong the conflict, which has displaced almost half of the country's estimated 15 million to 17 million people and left perhaps a million of them dead or maimed.

While Afghan communist leader Najibullah is considered intolerable by the resistance leaders and refugees in the camps that dot the Pakistani countryside near here, the Kabul authorities and more moderate figures in exile are just as opposed to giving future power to fundamentalist Moslems, such as resistance chief Gulbuddin Hekmatyar.

Soviet Foreign Minister Eduard Shevardnadze's visit last week to Kabul, in which he expressed the desire to make 1988 the last year in which Soviet troops would occupy Afghanistan, was widely viewed as a blunt warning to the Afghan communist leadership to cooperate more fully with the negotiating process. He even dropped hints that Moscow would be willing to see the People's Democratic Party assume a secondary role in a new Kabul government, an idea not likely to sit well with Najibullah.

In Peshawar, where the main Afghan groups fighting Soviet forces in their country have their offices, the pressure of what the diplomats call the "end game" has revealed submerged animosities among them. Groups within the seven-party rebel movement are trying to position themselves for a postwar regime. These tensions could ultimately hinder the emergence of a stable Afghan government after the Soviets leave.

The anxiety over such conflict induced U.S. and Pakistan diplomats to warn this week that major details of a pullout agreement need to be resolved before the current round of negotiations can lead to a real conclusion of hostilities and defuse future political turmoil.

There are few who believe that the Afghan conflict simply will come to an end and that peace and calm will suddenly descend on a land that has historically seen violence among its deeply divided ethnic and tribal groups.

Some observers believe that if the Russians withdraw their troops from Afghanistan, the country could slide into another period of chaotic rule by regional tribes and strongmen before some sort of central government in Kabul restores order.

"There are about six or seven really strong regional commanders within the mujaheddin {Moslem "holy warriors"} and it may well be that they will divide the country up with no real control from Kabul for awhile," said one analyst.

"There is bound to be some settling of scores and also probably a falling out among resistance forces, but it likely won't last too long. After all the fighting and killing, people are tired of it," said another analyst.

Under this scenario, the Peshawar-based leaders of the mujaheddin might suddenly find themselves less significant in a postwar Afghanistan and the commanders of forces inside the country would assume political as well as military power. Others say that the local commanders will listen to their political leaders, although perhaps not all of the seven Peshawar-based leaders would emerge in postwar positions of influence.

It is this last prospect that seems to be prompting what one long-time observer of mujaheddin politics calls a "sorting out" among the alliance groups. Hekmatyar, leader of an Afghan faction called Hezb-i-Islami, has been singled out by supporters of other political groups and by knowledgeable Pakistanis as the leader most prone to using a heavy hand to try to limit the power of others and enhance his own.

"We have been waiting for the alliance to come up with a formula for the future government," said one diplomat this past week, adding that the process has been a slow one.

The leader of a traditionalist -- as opposed to fundamentalist -- resistance group agreed. "At the moment it is under consideration. We hope we can develop a common approach," said Ahmed Gailani.

There are suggestions that the next round of U.N.-sponsored talks on a settlement in Afghanistan could take place within the next couple of months. But some observers fear that the alliance may be too cumbersome to set out a program other than a unanimous position on what they will not accept: the participation of any of the present officials of the Soviet-backed Peoples' Democratic Party.

Pakistani officials expressed confidence that when the time comes they will be able to enforce a degree of cooperation by all the guerrilla groups. "The arms flow can suddenly dry up and for those who depend on contacts and supplies from Middle Eastern countries, maybe passports and travel documents won't be so easily available," said one observer.

"When the arms aren't forthcoming any more, we will see how many commanders will stay loyal to certain groups," said a diplomat, echoing the same theme.

One scenario for Afghanistan's future currently being explored would set up a temporary government in Kabul that would include a representative of the mujaheddin, a person acceptable to Moscow, although not from the present Kabul leadership, and someone from among the westernized technocrats who served under earlier governments but fled the upheavals of the 1970s and 1980s.

Some resistance leaders believe that Afghanistan's former king, Zahir Shah, could play a unifying role in such a setup, but others are just as adamant that he is not an acceptable figure.

"He is the one who let the communists in in the first place," one alliance leader is reported to have said. Others are believed to be wary not so much of the king but of his son-in-law Wali.

"If the king does come, it will have to be as an Afghan leader," said one second-rank leader of the mujaheddin. "He can't come flying into Kabul on a Russian plane. He can't be seen as being their man."

With more than 3 million Afghan refugees estimated to be on their soil, Pakistani officials are said to be leery of any moves that will not lead to their permanent return home -- and they do not believe the refugees will return until they are certain the Soviet troops have gone and a semblance of order reestablished.

This is believed to have prompted recent statements by U.S. officials, including Secretary of State George P. Shultz, about shifting the formula for a cutoff of aid to the mujaheddin from earlier Geneva concepts.

Instead of cutting off all assistance as soon as a Soviet withdrawal begins, U.S. officials are talking about a phased withdrawal of aid that would match the phased pullout of Soviet forces. This has prompted Soviet warnings against "new conditions" for an agreement, but U.S. officials seem adamant that it is a major concern.

"Once the aid is cut off, the mujaheddin will be highly vulnerable if the Russians suddenly turn around and make a dash at them. And once the aid is cut off, Pakistan would find it extremely difficult politically to start the whole operation going again," said one diplomat.

There also are worries about monitoring and policing any resolution.

"What happens if local groups start attacking the Russians, or if the tribes controlling the Salang highway suddenly cut off food to Kabul?" one diplomat asked. Resistance spokesman Yunis Khalis has talked of guarantees for the withdrawing Soviets, but so far no one has spoken publicly of how these guarantees would be defined or whether they could be enforced on all parts of the alliance.