South African President Pieter W. Botha reacted angrily today to a suggestion by President Reagan that his government has released a number of political prisoners during the past week in response to diplomatic pressure from the United States.

Addressing a graduation ceremony at the University of Stellenbosch, of which he is chancellor, Botha insisted that South Africa makes its own decisions and that "no quiet diplomacy or shouting at us will prevent us from seeking the path of justice with the maintenance of civilized values in our country."

This was a clear repudiation of a claim made by Reagan last Friday that Washington's policy of "quiet diplomacy" with South Africa had brought about the release of 11 labor leaders detained under the country's stringent security laws.

Reagan made his statement in defense of his administration's low-key policy of "constructive engagement" with South Africa, which has been under attack by Washington demonstrators and other critics, including Novel Peace Prize winner Desmond M. Tutu. The critics claim it gives tacit encouragement to the white-minority government in Pretoria.In remarks taking note of International Human Rights Day last Monday, reagaan urged Pretoria to "reach out to its black majority" and called for more justice in South African society.

South Africa greatly values constructive engagement and was privately pleased at President Reagan's defense of it. But President Botha has his own political imperatives, the most important of which is that he dare not allow his conservative white supporters to gain the impression that he is yielding to foreign pressure.

To keep constructive engagement on track, he must deliver sufficient changes to enable the reagan administration to defend it in the United States but not so much as to give ammunition to his far-right critics in South Africa.

Botha's remarks were carefully couched in terms criticizing both the United States and the Soviet Union for interfering in Africa, and he said South Africa would not be influenced by "selfish" American or Soviet advice.

Reagan's call for change in South Africa's apartheid system of racial separation added to the chorus by black-led protesters at the South African Embassy in Washington and of Republican congressmen and senators who have criticized the South Africans.

South African officials initially publicly ignored the Washington protests, but the release of the detained labor leaders was widely viewed as an attempt by the South African government to defuse the protest movement in the United States once it had reached Congress and the White House, although South African officials have claimed that there was no connection.

Botha's statements today appear to reflect a growing irritation among South Africa's leaders at being the public target of prominent U.S. leaders.

Addressing the graduation ceremony, Botha said: "At the moment we are receiving a whole lot of advice from the international community on how to run our own affairs and those of southern Africa.

"The big superpowers -- Russia and America -- are writing out many recipes for us. But it is precisely their interference, and that of others, with Africa, for selfish purposes, that has brought the continent to the road of regression and collapse."

Botha asked: "Which example in Africa would they hold up as worthy of imitation? How many of Africa's people must still die of starvation before the superpowers will stop their power politics?"

United Press International reported:

Botha's comments came one day after three antiapartheid dissidents abandoned their 91-day occupation of the British Consulate in Durban, accusing the United States of "aiding and abetting" the racial policies of the South African government through the policies of constructive engagement.

Two of the men were immediately arrested again yesterday and charged with treason.

Botha spoke as Archie Gumede, 70-year-old president of the antigovernment United Democratic Front, and Asian opposition leader Paul David were charged with treason in a Durban court.

Gumede, David and Asian Dissident Billy Nair left the British Consulate in Durban yesterday after evading detention without trial under political security laws for 91 days.

"We feel this occupation has certainly achieved its purpose of focusing world attention on the shocking racial opposition and the evil apartheid system in South Africa," said Gumede.

The departure from the embassy came two days after the white-minority government, moving as Tutu received his Nobel Prize in Oslo, lifted detention orders against 14 persons, including the three who left the mission. But authorities immediately rearrested six of them and charged them with treason.

Eleven labor leaders also were freed last Friday following nationwide demonstrations in the United States against their detentions and after Tutu met Reagan to protest U.S. policy toward South Africa. The three activists were among six opposition leaders who took refuge in the consulate Sept. 13 to escape detention orders issued against them for their part in organizing protests against a new constitution introduced in September that continues to deny votes to the nation's 22 million blacks.