Pieter W. Botha was elected South Africa's first executive president today against a backdrop of widespread violence as black groups continued to demonstrate their opposition to the country's new constitution.

A powerful limpet mine was found shortly before it was set to explode in the provincial Supreme Court building in downtown Johannesburg today, and another wrecked an electricity substation in western Transvaal Province, cutting off power to a large farming area and trapping platinum miners underground for several hours.

At the same time, there were sporadic upsurges of the race rioting that has ripped through a dozen black townships in the Johannesburg area during the past four days, leaving 36 persons dead and an estimated 300 injured.

Nearly 150,000 black students stayed away from schools today as part of the widening protest movement, and many businesses in the riot-torn region were closed because black workers stayed home.

Botha's elevation from prime minister to executive president was a foregone conclusion. The electoral college that chose him had 50 members of his ruling white National Party, compared with 23 from the majority party in a new parliamentary chamber for the mixed-race Colored community and 13 from a smaller chamber for people of Indian origin. His nomination by the National Party went unopposed.

The president will be inaugurated Sept. 14 and will name a new Cabinet that may include nonwhites for the first time in South Africa's history.

Botha and his government have presented this breaching of the political color bar as an important reform in South Africa's segregationist system called apartheid, but leaders of the black resistance have rejected it as tokenism.

They contend that because the new constitution continues to exclude the 73 percent black majority from any role in the national government, it is really an attempt by the whites to co-opt the mixed-race and Indian minorities into an alliance against the blacks.

These black nationalists called for a boycott of elections for the new Colored and Indian representatives held Aug. 22 and 28, which resulted in less than 30 percent of registered voters in the two communities turning out.

The violence began during the boycott campaign, as police clashed with the black demonstrators and students who joined the protest by boycotting classes.

To this tense situation has now been added a rental increase in some of the black townships, which the poorly paid people living there say they cannot afford. This is what sparked the race rioting Monday.

Meanwhile, a black insurgent movement, the African National Congress, began stepping up a low-level guerrilla campaign with more bomb explosions.

There have been four bomb and mine blasts in downtown Johannesburg during the past two weeks, but casualties have been limited to a few injuries because the explosions have occurred after offices closed.

This appears to be in line with the African Congress' stated policy of aiming at military targets and government installations and trying to avoid civilian casualties.

The limpet mine found in the Supreme Court building today may have been an exception. Police said it was planted in the lawyers' robing rooms and timed to explode at 10 a.m., when the courtrooms in the building were due to begin the day's sessions.

A security guard spotted the plastic mine and, while a large central city area was cordoned off, a policeman carried it gingerly outside where it was detonated on a lawn.

The most violent disturbances today occurred in the black townships of Tembisa and Vosloorus, east of Johannesburg, where police used tear gas and rubber bullets to disperse groups of demonstrating students.

There also was continued looting in townships south of Johannesburg, where most of Monday's rioting occurred.

In Sharpeville, the main township in this area, there was a moment of high tension today as a crowd of more than 1,000 black residents confronted police in armored vehicles across a 200-yard stretch of no man's land.

It was reminiscent of a scene there 24 years ago when police on armored cars used machine guns on a crowd of passive resisters killing 69 of them and making Sharpeville a hallowed name to the black resistance.

The tension was broken when a priest carrying a white flag stepped forward from the crowd and walked slowly toward the big armored personnel carriers.

The priest, Ben Photolo, brought a message of conciliation from the crowd. They wanted to negotiate on the rent issue with officials of the white administration.

The request was accepted and the crowd elected a committee of six, which spent several hours in a nearby building talking with four white officials.

The meeting ended toward evening with the white officials offering to scrap the rent increase, but the township committee demanded that they go further and cut rents in half.

Mongezi Radebe, who led the township committee, told reporters that the residents demanded to be involved in negotiations with the white administration over the rents. He said they did not recognize the black council that decided the increase, because 95 percent of residents had boycotted elections to this council held last December.

Photolo said the white administrators showed "no empathy" during the meeting. "We are not a violent people," the priest added. "The rent increase was the last straw. These things build up over a long time. The whole system of government has become unbearable for the people."

Despite evidence that the new constitution has deepened rather than lessened the sense of alienation felt by many blacks, there is little evidence that white South Africans have been shaken by the events of the past few days.

Living areas for the different races are so compartmentalized under the apartheid system that whites are barely aware of what goes on in the black townships, except when an occasional armored troop carrier drives through a white area or a black employe fails to appear for work.

Compounding this racial isolation is the fact that South Africans are not avid newspaper readers, and the semiofficial broadcasting service has given only slight coverage to the disturbances in its radio and television newscasts. In some newscasts yesterday the rioting was not covered at all.