The six leading Afghan rebel groups based in Pakistan have pledged a new agreement to merge their treasuries, weapons stores and military forces in the battle against Soviet occupation of their country, according to Afghan emigre sources here.

The prospect of the merger's surviving the quarrels within the Afghan rebel movement and having a lasting effect among insurgents actually inside the country was greeted with skepticism by some Western observers here and in Pakistan. As late as last month, for instance, widespread factional fighting persisted across a broad area north of Kabul.

[In Washington, State Department officials also greeted reports of a merger cautiously. "Anything of that nature would likely be cosmetic and not greatly valid," said one informed official, who noted that similar reports in the past had been "greatly exaggerated."]

While the rebel groups based in the Pakistan border city of Peshawar have garnered most of the publicity and in many cases serve as paymasters and weapon suppliers to the revolt, there is a growing feeling that most of the actual fighting is locally controlled, outside the influence of the refugee hands.

But there are some indications that this unity move has a greater chance of success than others in the 18 months since the Soviet Union dispatched thousands of troops into Afghanistan. For one thing, Afghan sources here said, the leaders and members of all six major rebel groups based in Peshawar, on the edge of the Khyber Pass, signed a document sanctifying the merger.

Furthermore, the sources here reported that the Peshawar-based rebels face increasing pressure from some of the fighting bands within Afghanistan -- who themselves have begun cooperating more, according to reports here -- to stop bickering and form a united anti-Soviet front.

In Afghanistan's second largest city of Kandahar, local rebels were reported to have told representatives of the Peshawar groups to either unify or get out of the area.

The local anti-Soviet forces in Kandahar picked their own leader, a former Afghan Army officer known only as Col. Esmatullah. They told fighters from the groups based in Peshawar that they had to take orders from him while operating in their area. With the local help that rebels depend on for food and shelter threatened, the fighters from Peshawar agreed to serve under his command, according to information received by Afghan refugees here.

Other signs of cooperation among fighting groups in Afghanistan have surfaced in diplomatic reports and information filtering here from a variety of Afghan sources over the past few weeks.

Two months ago, according to Afghans here, fighters from Hesbi Islami, a leading Peshawar-based group, and SAMA, a local group centered near the Afghan capital of Kabul, began working together on military operations and loaning each other specialized weapons such as rocket-propelled grenades for stopping Soviet tanks.

In late June rebel groups from two different parts of the country joined in a battle against the Soviets in Paghman, the old summer capital of Afghanistan just outside Kabul.

"Common sense had dictated that the Afghans help each other," said one former Afghan government official, now a refugee here.

The greatest impetus toward the merger came from an increased willingness of the Hesbi Islami group of Gulbuddin Hekmatyar -- the largest and in many ways the most successful of the rival rebel camps -- to throw its lot in with the rest on an equal basis, the emigre sources said.

The Afghan sources here, whose information is impossible to verify because Afghanistan generally remains off-limits to Western correspondents, said Hesbi Islami was becoming increasingly isolated, especially since it cut its ties to Saudi Arabia, and was relying completely on financial and military support from Iran.

But Gulbuddin was reported to have realized that the chaos in Iran was hurting his movement and decided to join the other groups, a reliable Afghan source here said. Gulbuddin, a former engineer described as "a cunning, scheming person," sabotaged earlier attempts made under pressure from the Saudis and other Arab states to unify the Afghan resistance. In January 1980, he joined a united front for four days and then quit because he said Hesbi Islami was more powerful than the rest and therefore should dominate any confederation.

This time, however, he appears resigned to going in on an equal footing. Copies of a document merging the six Peshawar groups into the Islamic Unity of Mujahiddin of Afghanistan call for monthly rotations of the new units' leadership among the heads of the six member groups.

Moreover, the six groups will have equal representation on the governing council of the unified organization, close their individual Peshawar offices and end their separate activities, according to a copy of the manifesto, with three pages of signatures attached, that was received here.

The Peshawar organizations also agreed to put all their cash, military and nonmilitary equipment and property at the disposal of the unified organization.