President Pieter W. Botha declared a state of emergency, the first in 25 years, throughout vast sections of riot-torn South Africa tonight to crack down on a wave of violence that has killed about 450 persons in the country's black townships during the past 10 months.

Botha's sweeping order takes effect at midnight tonight and is for an indefinite period. It is the first emergency declared here since police gunned down 69 blacks at Sharpeville in 1960 and affects 36 districts in the central Transvaal region around Johannesburg and in eastern Cape Province.

Both regions have been scenes of intensifying unrest in recent weeks, clashes with riot squads and assaults against local black officials and police considered "sellouts" by government foes.

Spokesmen for opposition movements here immediately denounced the declaration, saying they feared that it would trigger new repression in South Africa and be used secretly to arrest and jail indefinitely anyone deemed an opponent or critic of white-minority rule.

In Washington, the State Department issued a statement saying, "We are deeply troubled by the ongoing unrest in South Africa, a situation that developed almost 11 months ago and has been worsening since then. All Americans are troubled by the events and feel deep sympathy for the many victims of violence in South Africa.

"The situation has deteriorated to the point that the South African government felt compelled to institute new measures," the statement added. "We hope sincerely that the unrest will abate rapidly, permitting the South African government to remove these measures and get on with the urgent business of reform."

The order gives the country's police and military virtually unlimited powers in the designated areas to search and seize property without warrants, and arrest without formal charge and hold indefinitely without access to lawyers anyone deemed a threat to public safety. The security forces also can seal off any of the areas, impose curfews and censor all news from the specified locations.

Anyone violating the terms of the order can be punished by 10 years' imprisonment and a $10,000 fine. Police actions taken during the emergency are not subject to judicial review.

Botha said he was ordering the move to combat "acts of violence and thuggery" that he said were "mainly directed at the property and person of law-abiding black people and take the form of incitement, intimidation, arson, inhuman forms of assault and even murder."

The South African leader's statement was underscored today by the killing of a black woman who was stoned, beaten and then burned alive by a mob that accused her of being a police informer. The incident, shown on the state-run television network tonight, occurred after a funeral for blacks killed in earlier unrest in the township of Duduza, 20 miles east of Johannesburg.

Police also reported that a black youth was killed today in a township near Port Elizabeth in the eastern Cape. The youth was hit by rubber bullets fired to disperse a crowd that had attacked the house of a policeman, the official report said.

Nearly two dozen persons have died during the past two weeks in township unrest, and the death toll for the past 10 months is estimated at 450. In the eastern Cape, scene of some of the most intense violence, police have reported arresting more than 2,000 persons.

Botha said his declaration was designed to give police the tools to end the violence, which officials blame largely on a relatively small group of instigators aided and inspired by the outlawed African National Congress, the main resistance movement fighting white rule. The ANC recently has called for a campaign to make the townships "no go" areas for police and other officials as a first step toward overthrowing the white government.

"I wish to give the assurance that law-abiding people have nothing to fear," said Botha. "At the same time, I wish to issue a warning that strict action will be taken against those persons and institutions that cause or propagate disruption."

Botha pleaded with "all well-meaning and reasonable South Africans to take hands in these times and to stand together to restore order and peace."

But the Rev. Allan Boesak, a Dutch Reformed minister who is a leader of the opposition United Democratic Front, said the state of emergency was designed to conceal police repression against legitimate opponents of the government.

"It is the kind of desperate reaction one can expect from this government, and it will not solve anything," said Boesak, who predicted that the move would result in "more violence and more killings."

The South African government has embarked on a series of measures in recent months that officials contend are designed to ease and eventually transform the strict legal code of racial segregation known as apartheid. Botha in his statement tonight said his emergency order was designed to "normalize" conditions here so that "dialogue in the interest of all people in the constitutional, economic and social fields" could continue.

But Frederik van Zyl Slabbert, leader of the Progressive Federal Party, the official opposition in Parliament, said the emergency declaration was a tacit admission by the government that its reform policies had failed.

"What was supposed to be the beginning of an era of negotiation and consensus politics has seen us drift steadily into the present state of semisiege," he said. "This government has neither the ability, the plans nor the talent to cope with the demands of genuine reform."

The last state of emergency was declared here following mass unrest in black communities after the Sharpeville killings. Hundreds were arrested and held for several weeks, and the country's two main black political movements were driven underground. More limited powers under a different law were invoked in 1976 following widespread unrest in Soweto, the sprawling black urban community west of Johannesburg.