South Africa's biggest trial of dissidents in more than two decades collapsed today when the state withdrew charges of high treason against 12 top black and Asian political leaders.

The state will continue to press the treason charges against four black trade unionists who were charged with the political leaders, but lawyers said the case against them also had been weakened seriously.

In the little red-brick courthouse in Pietermaritzburg, wild scenes of jubilation followed the announcement this morning by Michael Kimber, the attorney general of Natal Province. The government gave no reason for dropping the charges, but the key prosecution witness last week admitted "fundamental mistakes" in his testimony.

A statement issued later on behalf of the activist United Democratic Front, to which most of the defendants belong, said the trial had been "an attempt to criminalize and immobilize the opponents of apartheid."

"The world must understand that trials like this are a device to stop people resisting apartheid," said the Rev. Frank Chikane, one of the freed prisoners who is a member of the front's national executive.

Among those freed today were two copresidents of the UDF, Archie Gumede, 70, and Albertina Sisulu, 67, the wife of Walter Sisulu, a senior member of the outlawed African National Congress who is serving a life term in prison with its leader, Nelson Mandela.

[In Washington, State Department spokesman Charles E. Redman called the dismissals "an encouraging development." He said the United States remained concerned about the fate of the other four prisoners and would continue to monitor the situation closely.]

Some of the freed prisoners received a singing, cheering welcome by several hundred supporters at Johannesburg Airport. Several black leaders, able to speak freely for the first time in nearly a year, echoed the UDF statement and accused the government of abusing the legal process to silence them during a year of intense black political activity in South Africa.

The collapse of the case against the 12 already has exposed the government to the charge that it is using the courts as an extension of its detention system, bringing poorly based charges against legitimate political opponents simply to put them out of action.

Noting the defendants' detention for several months without charge, Norman Manoim, a defense lawyer, remarked: "One must assume they were detained on the strength of the same evidence that has now been exposed in court as completely worthless."

Twenty-two United Democratic Front leaders in a separate treason case are still being held for a trial set to begin on Jan. 20.

Some of those freed today -- including five of the "Durban Six" who sought refuge in a British consulate last year -- were first detained under security laws in August 1984. The others were arrested last February.

When they were charged in mid-year, the state issued an order prohibiting bail, which the defendants appealed and won. Bail of up to $5,500 then was set, but they were ordered to stay out of politics.

About half of the defendants freed today are black, the rest Asian. Those who remain on trial, and still face a possible death sentence, are Thozamile Gqweta, 32, national chairman of the South African Allied Workers Union, and union members Sisa Njikelana, 29, Sam Kikine, 36, and Isaac Ngcobo, 36. All are black.

The prosecution withdrew the charges against the 12 after its star witness, Isaak D. de Vries, a putative expert on revolutionary strategy, admitted under cross-examination last week that he had made "fundamental mistakes" in his testimony that could have misled the court, that his opinions were inconclusive and that he had misunderstood his role in the case. The judge then adjourned the case for two days for the state to consider its position in light of De Vries' admissions.

In other developments, four more persons died in racial violence in several parts of South Africa last night and today, bringing to 950 the number of deaths since the widespread unrest began in September last year.

Two blacks were killed when their home was set afire in Khayelitsha township, outside Cape Town, and the burned body of a woman was found in a Queenstown township in eastern Cape Province, police reported. Police said a 20-year-old man, wanted on public violence charges, was wounded and arrested in Khayelitsha.

One man died and 18 were wounded and arrested when police opened fire with shotguns and tear-gas launchers on a group of blacks who they said were stoning them at a gold mine west of Johannesburg.

Police reported today that two white soldiers had beaten a 60-year-old black man to death in a Soweto street late Saturday night, but later withdrew the report, saying the accusation against the soldiers was still being investigated.

The initial report said William Ncube was walking in a Soweto street when the soldiers confronted him and an argument developed.

The soldiers took off their helmets and beat Ncube to death with them, the report said.