TO REPLACE one sturdy Afrikaner, the ailing John Vorster, as prime minister, South Africa's white minority government has chosen another, Defense Minister Pieter Willem ("P. W.") Botha. Mr. Botha beat out Information Minister Connie Mulder on the second ballot. His margin was provided by the supporters of "liberal" foreign minister Roelof "Pik" Botha (no relation), who dropped out after the first ballot. Therein lies the riddle of white South Africa.

In a country that gave John Vorster a record victory in elections held less than a year ago, it is hardly a surprise that the National Party should replace him with someone in his mold. Mr. Vorster reflected the common Afrikaner determination to stay united as an ethnic community and to adjust to fiercely building internal and international pressures with as little loss of power and privilege as possible. P. W. Botha reflects the same determination. He is identified with two of the boldest Vorster policies. One was the intervention in Angola in 1975-76, a desperate and ill-fated effort to make common anti-communist cause in Africa with United States. The other was the effort, continuing, to offer a limited slice of political power to the small colored and Asian communities to split them off from the majority blacks.

The new prime minister has been widely described as a hard-liner. It is an image that no doubt accounts for some substantial part of his sucess in the National Party caucus. To be a hard-liner among Afrikaners, however, is not to be irretrievably tied to hard-line policies. Rather, it is to conduct policies, even moderate policies, that satisfy the Afrikaners' felt obligations to the Afrikaner community.

Pik Botha, outward-looking as befits a foreign secretary, evidently seemed to most of his peers too ready to accommodate international pressures; he was, too, a relative newcomer in party politics. Yet it is worth something that most of his supporters voted on the second ballot for P. W. Botha. The latter has the potential, if he demonstrates the requisite firmness, to make the accommodations in internal and external policies that Pik Botha seemed more obviously prepared to make.

The immediate test for the new prime minister is Namibia. John Vorster, in announcing his resignation, reversed his earlier decision to let the longtime South African colony move to independence under a United Nations framework negotiated by five Western powers.Mr. Vorster decided instead to move Namibia to independence under South Africa's own sponsorship - the recipe for international rejection of the result, for renewed guerrilla warfare and for new international efforts to isolate South Africa.

Can Prime Minister Botha find a way back to the conciliatory Namibian path on which Mr. Vorster had led South Africa before illness loosened his political grip? To the limited extent that it can, the United States should help him to do so. Few leaders have had to face a tougher challenge in their first days.