In the months immediately following the Soviet occupation of Afghanistan three years ago, most of the guerrillas battling the foreign enemy were armed with bolt-action rifles from the World War II era or even relics from the 19th century.

The courageous tribesmen appeared to be fighting a romantic but doomed struggle, carrying little more than devotion to Islam onto the field against a superpower. Lacking antitank or antiaircraft weapons, they seemed to have little chance of triumphing over Soviet troops armed with the latest models of tanks and helicopter gunships.

Today, the religious ardor has not changed, but the arms certainly have. The most common firearm among the insurgents has become the Soviet-designed AK47 or Kalashnikov, an automatic weapon often called the world's best assault rifle. More importantly, most guerrilla bands now have several rocket-propelled grenade launchers, bazooka-like weapons that can turn a tank or armored car into a flaming wreck from 300 yards away. They have shiny new mortars, mines and recoilless rifles.

The guerrillas captured many of these weapons from the enemy or obtained them from Afghan Army defectors, but an increasingly important source of supply is from across the Pakistani border. The United States, China, Egypt and Saudi Arabia have cooperated with the Pakistanis to guarantee a steady flow of infantry weapons to the insurgents, according to a variety of sources including Afghan resistance leaders, senior diplomats and local officials in Pakistan, and Western European military specialists.

The late Egyptian president Anwar Sadat provided the only public confirmation of foreign assistance, saying that he agreed to ship arms to the guerrillas at Washington's request. Egyptian and European sources say that the United States was paying between $20 million and $30 million a year to Cairo to cover the cost of the arms going to the insurgents from Egypt at least until the end of last year.

Since then, diplomats in Islamabad say that the new Egyptian president, Hosni Mubarak, seems to have reduced supplies to the Afghan guerrillas, perhaps to put some distance between his government and U.S. policies.

The steady increase in the number and sophistication of weapons at the disposal of the guerrillas probably has been the most important factor in ensuring not only the survival of the resistance movement but also the steady escalation that has marked the war in Afghanistan over the past three years.

The arms supply from abroad also has provided the Soviets with a ready justification for keeping their troops in the country. Moscow maintains that it will stay in Afghanistan until all outside interference ceases.

The supply line can be seen in action at the tiny frontier hamlet of Teri Mangal just inside Pakistan, an Afghan equivalent of a Wild West town of hastily constructed buildings, muddy streets and teeming crowds of armed men. There, scores of mujaheddin or insurgents crossed the border day after day carrying new Kalashnikovs with markings in Chinese or Arabic, or modified .303 rifles made either in Canada or the United States.

Passing the deserted ruins of what once was an Afghan border post, they goaded on mules, donkeys and horses loaded with a wide array of ammunition, grenades and heavier weapons.

The group of insurgents that I accompanied in Afghanistan waited three days in the nearby Pakistani town of Parachinar for arrival of weapons from Peshawar, headquarters of the Afghan resistance parties. The mujaheddin picked up their arms at a small Parachinar party office set up as a sort of distribution center.

The truck that arrived carried a variety of weapons of a sophistication that I had not witnessed during a previous visit last year: 150 brand-new Chinese Kalashnikovs with folding metal stocks; 300 khaki, plastic-covered mines, also from China; 15 mortars, both the British-made 3-inch variety and the Chinese 82mm type; four 82mm recoilless rifles, a kind of antitank cannon, each brand new, with Chinese markings, and 24 grenades.

I was told that supplies of this kind have doubled or tripled since last year, and that the center at Parachinar now receives such truckloads every three or four days. It is not the only distribution center, and it clearly showed that aid has been stepped up, that the mujaheddin rely increasingly on arms from outside, and that the weapons themselves have become far more sophisticated.

This impression was confirmed inside Afghanistan, where rocket-propelled grenade launchers, recoilless rifles and mortars were much more in evidence than a year ago. The overwhelming bulk of these relatively advanced weapons have come from outside Afghanistan, whereas the majority of rifles have been either captured from the enemy or were brought over by defectors, particularly during the first two years of the war.

The Soviet-designed RPG7 grenade launcher, with enough power to pierce Aernout van Lynden, a Dutch free-lance journalist who previously has written from Afghanistan for The Washington Post, filed this dispatch from London. He left Afghanistan after two months during which he accompanied insurgents. the armor of the standard Soviet T62 or T72 tank, has been the most important addition to the mujaheddin arsenal. Of about 60 guerrilla bands that I saw in the area south of the capital of Kabul, most were equipped with the weapon. The guerrillas have proved adept at learning to use the RPG7, which has given them the ability to go on the offensive against small Soviet units.

During an ambush of a Soviet convoy on the Kabul-Jalalabad road last year, I watched accurate firing of five RPG7s cripple all five vehicles--two armored personnel carriers and three trucks--in three minutes. That ambush illustrated that the resistance was capable of challenging Soviet control of the major roads, a possibility that few observers had thought likely when the Soviets invaded in December 1979.

Resistance officials tersely insist that they have purchased all of these new arms either on the open market or from the local, unsophisticated arms industry that flourishes legally in the tribal areas of Pakistan's northwest provinces. Pakistani authorities regularly have denied Soviet allegations that they were supplying the mujaheddin with arms.

But the Afghan, Pakistani and European sources interviewed for this article told a different story. Resistance leaders admit privately that they do not have enough money to pay for all the weapons that they are receiving. And while it is true that Pakistan is not giving arms to the mujaheddin, it is serving as the major conduit for funneling weapons into Afghanistan.

The sources said that a framework was set up, possibly under the coordination of the U.S. Central Intelligence Agency, to deliver arms from the four donor countries through Pakistan. The common factor uniting the donors is a fear of Soviet expansionism.

In confirming the foreign role in supplying arms, Sadat said in an interview with NBC News in September 1981, "The United States sent me airplanes and told me, 'Please open your stores for us so that we can give the Afghans the armaments they need to fight,' and I gave the armaments."

Sadat said that the arms were Soviet-manufactured weapons that had been supplied to Egypt before he expelled Soviet advisers in 1972. It was agreed that as far as possible, the arms should be Soviet or Eastern Bloc weapons that would help disguise who had provided them.

The Pakistani government agreed to participate in part because of a major military and economic aid package from the United States and assistance from China. It insisted that it would control the distribution and that the arms would not include sophisticated weapons that would contribute to a major escalation of the fighting, such as wire-guided antitank missiles or surface-to-air missiles.

China, long worried by what it calls Moscow's desire for "hegemonism" in Asia, apparently is playing a major role in the supply.

Most of the new arms that I saw had Chinese letters marking the settings for "safety" or "fire," and the Chinese appear to have an efficient intelligence network in Pakistan near the Afghan border. The morning after I returned from a three-month trip inside Afghanistan last year, without having told anybody of my arrival, two Chinese diplomats appeared at my hotel and tried to obtain information from me.

While the guerrillas have greatly benefited from the increase in supplies of weapons, they complain that their foreign suppliers have not provided them with a parallel increase in supplies of ammunition. And while they have proved to be proficient in handling the grenade launchers and recoilless rifle, they need training to employ their mortars efficiently. The mortar is not a very complex weapon but does require some understanding of mathematics, and none of the mujaheddin's benefactors so far has agreed to provide training.

The principal weakness of the insurgents, however, is the lack of some capability to defend against Soviet air attacks. The lack of protection against helicopter gunships and MiG fighter planes is a major topic of guerrilla conversation.

Because of this factor, daylight operations in areas close to Soviet airbases are almost impossible. Gauging from personal experience and that of other correspondents, the Soviets increasingly are using the gunship as the pivot of their counterinsurgency tactics.