Soviet and Afghan troops have mounted a campaign to dislodge rebel forces from mountain strongholds that are embarrassingly close to the capital city of Kabul, Western diplomats reported here today.

While the capital has been unusually free of assassinations or terrorist acts recently, the diplomats said fierce battles were raging within three miles of its center and a major government offensive was under way in the town of Paghman, 12 miles northwest of Kabul.

Rebels have been in virtual control of the Paghman area for most of the past year, and have used sanctuaries there to plan hit-and-run terrorist raids and assassinations within Kabul. Western reporters even have been smuggled into Kabul from the rebel bases in Paghman, underscoring the lack of control the Soviet-backed Afghan government has over most of the country.

Afghan officials rarely allow noncommunist reporters into the country, so most reports of fighting there comes from diplomatic sources.

The diplomats said Soviet and Afghan troops also appear to have launched attacks once more against Afghan rebels who have been firmly entrenched in the Panjsher Valley, about 60 miles north of Kabul.

The Panjsher, scene of two major Soviet-led campaigns against the rebels in the past 18 months, is considered strategically important because it allows guerrillas access to the large Soviet air base at Bagram.

Details of the latest Panjsher offensive were scanty, but the diplomats said it began last Thursday, when the Soviets used a new tactic--throwing up a pontoon bridge over the Panjsher River at Golbahar that allowed them to move up the valley. The diplomats also said the Soviets were using Mig fighters to strafe rebel enclaves before sending troops in.

These new offensives came at a time when United Nations-sponsored talks aimed at ending the Soviet Union's 29-month-old occupation of the rugged, Texas-sized nation appeared ready to take hold.

Scheduled for Geneva in mid-June, these will not be direct negotiations but rather indirect talks through special U.N. mediator Diego Cordovez between officials of Afghanistan and neighboring Pakistan. Iran, another neighboring state, will not participate in the talks but has agreed to monitor them. Both neighboring countries have refused to sit down with representatives of the Soviet-installed government of Babrak Karmal, although Pakistan has expressed a willingness to talk to Afghan officials in their role as leaders of the ruling Marxist party.

It is still unclear whether the Geneva talks will lead to anything, but they are the first real diplomatic move in almost a year.

It appears to diplomats here that in Afghanistan, the close to 100,000 occupying Soviet troops are trying to solidify their control in concentric circles around Kabul.

Besides moving on rebel forces in Paghman, with night-long battles last Wednesday and Friday that could be heard in the capital, the Soviets and Afghan government troops launched an attack last week in the Logar Valley, south of Kabul.

Furthermore, there were reports of a rebel ambush in which between four and 10 Afghan and Soviet soldiers each were killed at Pol-e Charkhi, three miles east of Kabul, on May 18.

Dislodging the rebels from Paghman would provide a major, highly visible gain for Soviet and Afghan authorities. The rebels had become so bold in that area that they ran six checkpoints on the 12-mile road from Paghman to the capital and had forced officials of the town's court to flee to the safety of the capital.

The road, furthermore, goes by Kabul's golf course, where diplomats continue to play, often with the expectation of seeing rebel activity against government forces.