The last Soviet soldiers had barely crossed the border for home Wednesday when the nation began hearing about the horror, the grief and even the atrocities of its nine-year involvement in Afghanistan.

The reports, carried in various Soviet newspapers, appeared just as the final contingent arrived in the border city of Termez, officially ending this country`s role in Afghanistan`s civil war.

''The day millions of Soviet people have waited for has come,'' Lt. Gen. Boris Gromov, commander of the Soviet forces in Afghanistan, said during a ceremony held just inside the Soviet Union.

''In spite of our sacrifices and losses we have fulfilled our internationalist duty totally.''

But the Afghan war had another side.

For the first time since its 1979 invasion, the Soviet Union spoke publicly of atrocities committed by Soviet soldiers in Afghanistan.

The respected weekly Literaturnaya Gazeta, carefully controlled like all other Soviet publications, reported that Soviet soldiers had apparently executed a group of innocent Afghan civilians on orders from a superior officer who said he did not ''need captives.''

The newspaper did not say exactly where or when the events took place, but from details included in the report it appeared to have happened in 1985 somewhere near the Afghan border with another country.

According to the story by Gennady Bocharov, one of the country`s more seasoned war reporters, a group of Soviet soldiers with orders to interdict weapons being smuggled to Afghan guerrillas shouted at a car to stop as it approached a border checkpoint.

''The soldiers ordered the driver to stop,'' Bocharov wrote, ''but he just accelerated. It can`t be ruled out that it just seemed that way to the soldiers.''

The story said that the troops fired warning shots into the air, and when the car didn`t stop, they fired at the automobile. The newspaper said that when the car eventually stopped and the soldiers searched it, they found no weapons.

But they discovered a dead woman, a wounded man and a wounded teenager who had been hit in the hail of bullets. Four other passengers, including an old woman and two children, escaped unharmed.

At that point the commanding officer of the patrol said he would radio his superiors and call for a helicopter to come and take the civilians away.

When he contacted his superior, identified only as Rudykh, the officer said that he had no interest in prisoners.

''I don`t need them,'' the newspaper quoted Rudykh as saying. As if for emphasis, or as if seeking support, the newspaper said, Rudykh repeated himself. ''I don`t need them.''

He ordered the men to take care of the situation ''quietly'' and to dispose of all of the ''traces.'' The article did not say specifically what happened to the civilians, but it clearly implied that they had been executed. The newspaper said that a trial was held in the Soviet city of Tashkent and that Rudykh and a soldier who actually carried out his orders, identified only as Pvt. Shmakov, were sentenced to five and six years respectively. The commander of the patrol was hit in the head by shrapnel shortly after the incident and was never brought to trial.

Rudykh was set free a few months later as part of an amnesty marking the 40th anniversary of the end of World War II.

This and other reports in Literaturnaya Gazeta Wednesday as well as letters published by other newspapers appeared to be the latest step in a government effort to portray the involvement in Afghanistan as a tragic mistake.

Literaturnaya Gazeta also gave details of the rage and sometimes madness of Soviet soldiers sent off to fight in a country they could not fathom.

In the same article, Bocharov told a story of a group of Soviet soldiers who stole gasoline from a helicopter and used it to burn the bodies of Afghan rebels they had just killed.

''We could hardly breathe from the stink and we cursed,'' the story quoted the soldiers as saying.

It said they went on to shoot and burn the camels that the rebels had been riding and that one rebel who escaped, albeit with a broken pelvis, was picked off by a Soviet sniper.

''Perhaps he had decided he had saved his skin,'' one of the soldiers said of the escaping rebel. ''We shot him too.''

The story also spoke of the growing disenchantment and eventual revulsion Soviet soldiers had toward Afghans because the Soviets could never decide if they were friends or foes, allies or spies.