Nine persons, most of them political refugees from South Africa, were killed in a raid just after midnight today on two homes in the capital of this small black enclave country.

The government of Lesotho accused South Africa of conducting the raid, sending a strongly worded protest note to the Foreign Ministry in Pretoria. South Africa denied responsibility for the raid.

A man claiming to represent the Lesotho Liberation Army -- a rebel group trying to topple the government of Prime Minister Leabua Jonathan -- telephoned a Johannesburg news agency tonight saying the rebel organization had carried out the raid, but it was unclear what motivation a rebel group would have in attacking South African political refugees in Lesotho.

Officials and witnesses interviewed in Maseru today were emphatic in holding South Africa responsible.

"There is absolutely no doubt about it," said the Lesotho prime minister's press secretary, Tsoeu Ntsane. "This was a South African raid, period." He dismissed the alleged rebel claim as "a joke."

Ntsane said Lesotho had received a diplomatic note from Pretoria only two days ago that claimed that guerrillas of the underground African National Congress were operating from Lesotho territory and warned of retaliatory action.

The raid also follows the death Sunday of six white civilians, including four children, in a land-mine explosion on South Africa's northern border with Zimbabwe, and emotional calls by the government's white Afrikaner supporters for retaliation against the African National Congress, which admitted planting the mine.

Meanwhile, South Africa is reportedly carrying out a retaliatory raid deep inside Angola against insurgents of the Namibian independence movement, the South-West African People's Organization.

In the Lesotho raid, witnesses said that a raiding party of 10 white men in brown "overalls" who spoke Afrikaans, burst into a house where seven black refugees were holding a Christmas party and killed the four women and three men with 9-mm automatic pistols fitted with silencers. South African Army uniforms are brown, and Afrikaans is the main language spoken by white South Africans.

From there, according to Lesotho police, the commandos moved to an apartment a mile away where they shot and killed a mixed-race South African refugee, Joe Quinn, and his white wife, Jacquelina. Their 1-year-old son was left unharmed in his crib.

The raiders then drove to the banks of the nearby Caledon River, which forms the border with South Africa, where they stripped the registration plates from their two getaway cars, set fire to the vehicles and crossed into South Africa.

Ntsane said the Lesotho government had still not established the identity of all the people killed, but it believed "three or four" were Lesotho citizens and the rest South African refugees.

He insisted that the South Africans were "genuine refugees" and not African National Congress insurgents using Lesotho as a launch pad for attacks against the white-ruled republic that completely surrounds it, as the Pretoria government alleges often is the case.

"We give sanctuary to genuine refugees, but we do not allow guerrilla activity from our territory," Ntsane said.

Willie Lesole, who owns the house where the main attack took place but lives next door, is one of the few people who said they saw the attackers.

He said in an interview that he heard screams coming from the house shortly after midnight. He knew his tenant was giving a party and thought a drunken brawl might have broken out, so he went to investigate.

"As I came around to the front of the house I saw a white man in a brown overall standing there. He had a long pistol in his hand. The street lights were on and I could see him very clearly," Lesole said.

"I saw him lift the gun and aim at me," Lesole went on. "I dived behind a wall and ran between the buildings. This man chased me and I heard him fire three shots, but the gun didn't make a big bang. It just went thwip, thwip, thwip, and I heard the bullets hitting the wall next to me."

Another neighbor, who would not give his name, said he saw one of the party guests shot down as he ran from a back door of the house toward his car parked in a side street.

He, too, said the gunman was dressed in brown.

Inside the house was a scene of carnage. Blood was smeared everywhere, trails of it showing where the dying had struggled vainly to reach help. Bullet marks scarred the walls, and flattened slugs and empty 9mm cartridge cases littered the floors. The bathroom, where three bodies were found, looked like a slaughterhouse.

From a wall in the sitting room, a large portrait of a black mother and child gazed serenely down at the gory scene.

According to Information Secretary Morapedi Motaung, the Lesotho police suspect that the Christmas party was a carefully laid trap.

They noted that the host, a South African Colored, or mixed-race, man, invited a number of political refugees to the house, then excused himself just after midnight, saying he had an urgent appointment.

At the same time his wife, child and sister-in-law withdrew to an outside room, telling guests the sister-in-law had drunk too much and was feeling unwell.

About 30 minutes later the raiders struck.

An examination of the bodies in the Maseru mortuary showed that most had been shot in the head, an indication that the raiders were skilled gunmen.

The destruction of the automobiles on the river bank also bore the stamp of a professional operation. The two cars, only barely recognizable as Volkswagen Jettas, were parked side by side, soaked with gasoline and set ablaze with their hoods propped open, so that the intense heat engulfed the vehicles and obliterated all identification marks.

This is the second time in three years that there has been a raid on South African blacks living in Lesotho. In December 1982 a South African commando force attacked a number of houses in Maseru, killing 42 people who it claimed were African National Congress guerrillas.

The Jonathan government claimed at that time also that at least a quarter of those killed were Lesotho citizens, and the rest "genuine refugees."

South Africa has carried out similar reprisal attacks on what it claimed were African National Congress "bases" in the Mozambique capital of Maputo, and, last June, the Botswana capital of Gaborone.

It has put particular pressure on Lesotho, accusing it of being a persistent supporter of the African National Congress guerrillas, and for a time in 1983 South Africa choked the flow of traffic into the enclave country by tightening border controls.

Faced with this pressure, Lesotho began evacuating South African refugees last year to other African states willing to accept them. Ntsane accused South Africa today of obstructing the evacuation, but Pretoria denied that.

Ntsane said South African military aircraft had intercepted a Zambian Airways plane with 150 refugees on board Dec. 3 and forced it to return to Maseru.

Most of those refugees have been flown out since then on three regular Lesotho Airways flights, Ntsane said, but South African civil aviation authorities had refused clearance for a fourth group to overfly South African territory.

The press secretary said he did not know whether any of these refugees were among the victims of today's raid.

A Defense Force spokesman in Pretoria "categorically denied" tonight that South African military aircraft had forced a plane carrying refugees from Lesotho to turn around.