In an apparent bid to avoid a confrontation with the United States and its Western allies, South Africa said yesterday it has decided not to turn over control of Namibia to the local leaders who win the disputed elections being held there this week.

On the surface, the decision appeared to be a major concession to Western demands that South Africa drop its go-it-alon plan for Namibian independence and allow the United Nations to supervise the transition to self-rule in the vast territory on South Africa's northwestern border.

Western diplomatic sources warned last night, however, that it is too early to tell whether the South African move is a genuine attempt to get into line with U.N. plans for creating an independent Namibia or simply a stalling action in a larger scheme to retain Pretoria's influence over the territory.

For the United States and its allies, the distinction is of crucial importance because Namibia represents the biggest test to date of the West's determination to prove that the blackwhite racial conflicts of southern Africa can be solved peacefully.

The intensity of Western concern was underscored last week when President Carter met with South African Foreign Minister Pik Botha and warned him of "real problems" if Pretoria fails to cooperate with the United Nations.

Although the details of what Carter said have been kept secret, he is believed to have told Botha that the West will support limited economic sanctions against South Africa if it defies the United Nations.

The U.N. Security Councili scheduled to meet today on Namibia and there had been expectations that the black African countries would press the council for an immediate sanctions vote. However, the sources said, the latest South African gesture probably will lessen this pressure and allow the West, which wants to avoid sanctions, to argue that Pretoria should get more time to demonstrate good faith.

Details of the South African decision were communicated to U.N. Secretary General Kurt Waldheim on Saturday and made public by Prime Minister Pieter Botha's government last night. Washington Post correspondent Carlyle Murphy reported from Windhoek, the capital of Namibia, that the announcement included two potentially significant points.First, South Africa gave assurances that it will remain the legitimate authority in the territory it has ruled for 58 years after the elections being held this week under its direction. That relieves, at least temporarily, Western fears that Pretoria would say it no longer has any authority in Namibia and that other countries will have to deal with leaders chosen in elections that the West does not recognize.

In addition, South Africa said it will complete consultations on plans for U.N.-supervised elections with the leaders elected this week and repor the results to Waldheim by the end of the month. That hinted that South Africa plans to comply with a Jan. 1 deadline for implementing the U.N. plan and intends to talk those elected this week into rubber-stamping the decision.

These were the latest moves in a tortuous cat-and-mouse game that began last July when the Security Council voted to accept a plan, negotiated at the instigation of the United States and four allies, for independence of the territory formerly known as Southwest Africa.

After first accepting the U.N. formula, South Africa backed out in October because of fears that U.N. administration of elections leading to independence would give power to the Southwest Africa People's Organization (SWAPO), which has been waging guerrilla war with Soviet support against Pretoria's rule for more than a decade.

South Africa said it would run its own elections in Namibia -- a move seen in black Africa as an attempt to keep SWAPO out of power while installing puppet leaders.

After Western foreign ministers visited Pretoria, a confusing and ambiguous deal was made. South Africa, while insisting on this week's elections, said it would try to persuade those elected to cooperate in U.N.-organized elections next spring. The West, although refusing to recognize the current elections, said it would regard the South African promise as meaning that the U.N. plan is still on track.

Since then, the Western powers, faced with black African suspicion of the arrangement, have been counseling patience and time for South Africa to make good on its promise.

As diplomatic sources noted last night, the latest developments leave that situation basically unchanged. They can be interpreted either as a step by South Africa in the West's direction or an attempt to string the West along. Only the events of coming weeks will tell which is correct, the sources said.

Murphy added from Windhoek:

Six top SWAPO officials were arrested by police at their homes in the black township of Katutura outside Windhoek early yesterday morning.

The arrest of the SWAPO leaders, including top official Daniel Tjongarero, apparently is in retaliation for two bombs that exploded in Windhoek's downtown shopping area Saturday morning, injuring 14 per sons.

The six are being held under strict security laws that permit detention without trial indefinitely.

Most observers expect they will not be released until after the five-day election period this week. The nationalist movement denied any responsibility for the bombings.

Despite the police action, nearly 5,000 SWAPO supporters gathered at a rally yesterday in Katutura to condemn the election. Speakers questioned the validity of the election and made it clear SWAPO adherents should not vote.

The assurances South Africa has given U.N. and U.S. officials are certain to provoke criticism from the party expected to win the election, the South African-backed Democratic Turnhalle Alliance. The South African-appointed administrator general of the territory, Marthinus Steyn, has already said that the 50-man constituent assembly to be set up by the election's winners, will meet before the end of this month.