New Delhi — Soviet soldiers in Afghanistan killed 45 civilians and wounded 17. Others in a machinegun attack in revenge for the slaying by rebels of an Afghan regime official, Western diplomats said Tuesday.

Diplomatic sources said Moslem guerrillas shot to death ‘‘an important regime official’ on Jan. 17 in the teeming marketplace of Kandhar in southern Afghanistan, 300 miles southwest of Kabul.

In revenge, Soviet troops in the city ‘“opened fire indiscriminately, killing 45 civilians and wounding 17 others,”’ one diplomat said during a briefing for Western reporters. ’

Before the fatal attack on the unidentified official, guerrillas fired mortars at the Kandahar airport Jan. 12, said the diplomat, who spoke on condition he not be identified.

“Kandhair airport was attacked and two aircraft destroyed,” a diplomat said, ‘‘Soviets retaliated, attacking suspected hideouts of guerrillas in Kandhar city and its suburbs, killing many civilians.”

Rebels seeking to oust Soviet troops, who invaded Afghanistan in December, 1979 to back the government. Of President Bakrak Karmla, killed “many Soviet troops,” in several successful attacks on military positions during the past month, diplomats said.

The reports could not be independently confirmed because Afghanistan does not permit Western journalists into the country.

There have been reports from ‘‘multiple sources of the Soviet atrocities’’ near the towns of Charikar and Shakardara north of Kabul in the Panjshir Valley, where Russian troops have failed in seven campaigns to oust guerrillas.

The diplomats said Soviet forces may be preparing a new attack in the mountainous valley, a strategic region where rebels have had repeated success in attacking Russian supply convoys from the Russian border.

On Jan. 25, a large contingent of Soviet troops was seen at Charikar in northern Afghanistan, apparently on its way to the Panjshir, one source said.

During the following five days, several Soviet convoys of hundreds of tanks and trucks were seen moving north from Kabul toward the 100milelong valley, the sources said.

Article extracted from this publication >> February 8, 1985