SOUTH AFRICA is edging back toward the respectable position on Namibia (its colony, as South West Africa, for 50-odd years) from which it departed last fall. Up to that point, Pretoria had been moving toward acceptance of the Namibian independence plan that five Western nations had sold to a skeptical United Nations. Then, in a setback brought on by the convulsions of a political succession crisis, South Africa started cutting loose from the Western plan. It sponsored internal elections, transparently designed to exclude the SWAPO nationalists, who by that time had been persuaded to suspend their guerrilla operations and compete in elections under U.N. supervision.

Those internal elections were duly held. But -- here is the good news -- it now appears that South Africa will not hand over power to the winners, a course that would have ensured a resumption of guerrilla war. Instead, Pretoria will use its dominant influence in Namibia to get the internal people to participate in all-party U.N. elections next year.

It's far from a sure thing. But optimism is running high in the Carter administration; just the other day Richard Moose, the assistant secretary of state for Africa, described the U.S. effort in Namibia as "the most successful undertaking in Africa this year." The multiracial Democratic Turnhalle Alliance, after sweeping the internal elections, has agreed to the broader elections. Its victory gave it new confidence, and it was under South African pressure. But it is understandably apprehensive about submitting its fortunes to a poll run by the U.N. General Assembly, which has officially anointed one (electorally untested) Namibian faction, SWAPO with its guerrillas, as the sole legitimate representative of the Namibian people. On its part, SWAPO is apprehensive, also understandably, lest South Africa use its substantial military weight in the territory to inhibit a free and fair vote.

So even though South Africa, the DTA, SWAPO and the U.S. officials are all now saying the U.N. elections will go on, there will still be considerable sparring over the terms. The United States and the four other Western countries that are holding the ring have their work cut out for them in the next few months.

If this political rescue operation does come off, it will not be merely because the DTA realized the value of international legitimation and SWAPO the value of internal accommodation. It will also be because various sovereign states came to realize their own distinctive stakes in a peaceable Namibian outcome. South Africa needs such an outcome to consolidate a friendly, stable state on its northern border, to keep Cubans from eventually widening the Angolan war, and to demonstrate its capacity to be reasonable, and not just defiant, in its own interest. Angola, which has been urging moderation on the SWAPO guerrillas (which it supports), needs a peaceable outcome also to have a friendly, stable neighbor on its southern border, to reduce South African support of Angola's own opposition guerrillas, and there by to relieve its dependence on Cuban soldiers -- the better then to improve relations with the West.

The United States has correctly seen Namibia as the one place in southern Africa where a diplomatic solution under American patronage, rather than a military solution under Soviet patronage, could work in a reasonably short time. This would fully justify itself in strictly Namibian terms.But the example of racial and ideological accommodation, American officials hope, would be at least partially portable: It could be carried to Rhodesia and perhaps to South Africa itself, both places where the expectation of violence has a strong tendency to become a selffulfilling prophecy. That is why American diplomacy needs a success in Namibia, and so does southern Africa, desperately.