The Soviet Union is testing some of its most sophisticated tactical weapons against rebelling Moslem tribesmen who have seized control of much of the Afghan countryside.

The Marxist government, still shaken by a violent change of leaders last month, holds only the major cities and some of the farm land.

Military involvement by the Soviets is their most extensive in any current world conflict, surpassing that in Ethiopia last year and in Vietnam earlier this year.

While the Soviet Union is not believed to be directly committed in the fighting in this Texas-sized country strategically located on its southern border, most diplomatic observers here think there are Soviet advisers down to the company level and Soviet pilots and gunners flying some helicopter gunship missions.

In addition, the Soviets have taken over the Bargam air base 40 miles from here to handle the incoming flights of giant Antonov transport planes laden with military hardware from the Soviet Union. Some diplomats believe the Soviets have from 500 to 4,000 troops guarding the base perimeter.

Among the weapons coming here is the $2 million MI24 helicopter gunship, believed to be the most advanced in the world, which is getting its first combat test against the rebels.

According to military attaches stationed here, the gunship looked "impressive" as it poured machine-gun and rocket fire on a line of tanks headed toward the People's Palace during an abortive coup attempt in August.

That was the first time outsiders even have seen the MI24 in action, even though Soviet and Afghan pilots and gunners have been using it against the rebels since March.

Looking like a giant dragonfly spitting bullets, it has "changed the face of the fighting here," said one non-Western military attache with experience in Vietnam.

The gunship enables the government to move quickly and decisively against rebel attacks anywhere in the country. "It comes down low, moves slowly and picks its targets. The rebels cannot escape," said one observer.

While the new Soviet equipment pours in -- 30 gunships, with 20 more in the pipeline, about 800 million-dollar tanks, 800 armored personnel carriers, and artillery -- Afghan strongman Hafizullah Amin is trying to convince the world and his country that he is firmly in control. A palace coup in mid-September deposed former Nur Mohammed Taraki.

This capital is surprisingly calm so soon after a violent coup that left the ruling Khalq Party and the military shaken. Soldiers guarding the Foreign Ministry carry no ammunition clips for their unloaded rifles. Tanks are gone from the center of the city and sentries appear more relaxed than previously when they stop people traveling at night.

But diplomats and Afghanis alike still wonder if Amin holds a winning hand or if he is playing a big bluff, hoping that his confident manner will scare off the opposition.

"The time of doubt is not yet over," said an Afghan official.

One well-placed Asian diplomat said of Amin, "I have written his obituary already. I see no way he can survive." But another equally well-placed diplomat believes the massive influx of Soviet military equipment has put the rebels on the run for the first time since the insurgency started one year ago and that Amin is firmly in charge of the government.

"The coup hasn't really affected the country, its foreign policy or its internal affairs. It was just a family fight," he said.

Amin, the number two man to Taraki before the coup, is clearly trying to improve his image. To gain support of the largely Moslem population, he announced a program of painting mosques. He daily reports the numbers of political prisoners who have been freed; he has set up a large commission to draw up a constitution, and he proudly proclaims the aims of his government as legality, security and justice.

But most Afghanis hold Amin responsible for the hard-line policies that he now seems to be trying to moderate.

It is hard to gauge how much support Amin actually has. His move against Taraki has split the Khalq party and his attack on the last three Army officers in the Cabinet has alienated some segments of the military. Even his Soviet protectors, surprised by his takeover on Sept. 14, are believed by some here to be wavering in their support for him.

Most Afghanis are afraid to oppose the government publicly. One man, though, snapped off the radio as it was playing a new Khalqi hit tune, "Celebrate, Celebrate, You Are Free," and said:

"Our hands are tied and our eyes are blindfolded. You call that freedom?"

But Amin now appears confident enough of his strength to begin the process of tearing down the image of Taraki, the 62-year-old poet-journalist who was the father of the Khalq Party. Amin first said that Taraki had resigned because of ill health. But in a red-bound, six-page pamphlet that was in limited circulation among party members last week, Amin accused Taraki of attempting an assassination plot against him.

The booklet also attacked as traitors "the gang of four" -- the last three in the Cabinet, who were fired by Amin just before the coup, and the former head of the secret police.

The public does not know where the four are, or even if they are still alive. According to the most prevalent rumors here, they have either been given sanctuary in the Soviet Embassy, escaped to the Soviet Union, or joined with other insurgent army men in the hills to fight the government.

At least one of the four, Lt. Col. Mohammed Aslam Watajar, is a hero of the 1973 revolution that ended the monarchy and the 1978 coup that put the Khalqis in power. He is believed to have a strong following in the Army as well as among the public.

"If I was Amin, I wouldn't sleep well at night knowing those four were around," said one diplomat.

But Amin has the armed might of the Soviets behind him. Reluctantly or not, they never stopped pouring supplies into Afghanistan, even if -- as most diplomatic observers here believe -- they were unpleasantly surprised by the way he grabbed power.

These supplies give the Afghan government a technical superiority over the five discordant rebel groups in much the same way that U.S. arms gave South Vietnam a technical edge over the Viet Cong and the North Vietnamese.

Military men here believe that weapons superiority means the end of the rebellion. But others say the rebels will retreat into the rugged terrain where modern weapons do little good, and wage a hit-and-run war against the government.

The rebels' main success has come in that kind of fighting. They have, for example, forced the virtual closing of some of the country's major roads, especially in the west between Herat and Kandahar, and Kandahar and Kabul. Armed convoys on those roads run a 50-50 risk of being ambushed. According to sources here, when Mig fighters tried to rescue one ambushed convoy recently, they fired on the travelers instead of the rebels.

One thing seems clear, though. The Soviets are not going to give up their role in Afghanistan. Not only are they bound by Marxist dogma to the present government, but any weakening of Soviet resolve here would encourage minorities at home and in the East European satellites to push for more independence, diplomats said.

But that does not mean the Soviets are wedded to Amin. There is a strong feeling among diplomats here that the Soviets might engineer their own coup, replacing Amin with someone who could strike a bargain with the rebellious tribesmen by backing off from some of the changes that go against tradition and religion, and by giving more power to the tribal chiefs.

"The governments that last longest in Afghanistan are those that govern least," said a diplomat, "and the Soviets know that."