A last-minute compromise apparently has defused friction between Prime Minister Pieter W. Botha and the leader of the South African-backed administration here, heightening political confusion in Namibia (South-West Africa) even as the United States and South Africa seek to break a deadlock on negotiations over the territory's independence.

Botha announced Saturday that he would extend the interim administration of Dirk Mudge, the white leader of the Democratic Turnhalle Alliance, by three months.

Two months ago Botha had written off Mudge as a failure and said he planned to replace him and find another alternative to the radical South-West Africa People's Organization (SWAPO) if elections are held here prior to independence.

With the deadline for the expiration of Mudge's five-year term a day away, both men compromised. "I think I have won my point," Mudge told a press conference Saturday.

Botha cited only the continuing U.S.-led negotiations as his reason for extending the administration's term. He said an "internal" poll -- one that would exclude SWAPO, whose guerrillas operate from bases outside the territory -- to elect a new administration was "undesirable and impracticable" while the negotiations were in progress.

Namibia was also paralyzed by the worst drought of the century and was in no condition to have an election, Botha said.

But in three months there should be greater clarity on whether the negotiations were going to lead to a settlement in Namibia with internationally supervised elections, he added. If not, an internal election for a new administration could be held.

The episode has been interesting mainly as a symptom of the confused state of Namibia's internal politics and for the effect it may have on South Africa's willingness to go through with an independence settlement for the territory.

The South Africans are anxious to prevent a SWAPO takeover if the settlement comes about. They regard SWAPO as a Soviet surrogate, and Defense Minister Magnus Malan has said several times that South Africa cannot allow the red flag to fly here.

Security considerations aside, the thought of a SWAPO election landslide, such as the one that brought Robert Mugabe to power in Zimbabwe in 1980, gives the Pretoria government political nightmares.

It is already worried about a strong backlash among its traditional Afrikaner supporters against constitutional reforms giving limited political rights to some nonwhites in South Africa. A second backlash, if Botha had to hand over Namibia to SWAPO, could challenge the government directly.

An opinion poll just published in South Africa underlines the point. It shows 70 percent of the country's whites do not consider it necessary even to negotiate with SWAPO.

Ever since the search for an international settlement began under the Carter administration, South Africa's prime objective has been to build up a political coalition that could beat SWAPO at the polls.

It chose Mudge's Democratic Turnhalle Alliance, an association of ethnically based parties from 11 population groups, to play this role, and South Africa has done everything it could to help the alliance build its image.

Mudge's group was set up as a provisional government, but its image suffered because it was blamed for the continuation of segregationist practices it could not change because of a complicated constitution imposed by South Africa.

Meanwhile, despite South African military successes against the guerrillas, intelligence reports indicated that SWAPO's political prospects continued to improve, and Botha decided that Mudge was to blame. He accepted a plan devised by his administrator general in Namibia, Danie Hough, to revamp the internal administration.

The plan would have resulted in Mudge being replaced as chairman by Peter Kalangula, a black former alliance president who broke with Mudge's group in February and whom the South Africans earmarked as their new man.

Mudge refused to accept the plan. He threatened to pull the alliance out of the administration altogether and to boycott new elections.

Botha, impatient at Mudge's resistance, ordered Hough to come up with a solution in seven days. Hough reported back that he could not.

The matter remained deadlocked until, with the administration's term running out, Botha, Foreign Minister Pik Botha, Malan and several generals flew to Windhoek Friday to resolve the issue.

That lead to Botha's announcement Saturday, in which he also named Hough's replacement, Willie van Niekerk.

The political confusion has done little to enhance the U.S.-led negotiations on Namibian independence, which have been deadlocked for three months over South Africa's insistence that there can be no final agreement until the estimated 20,000 Cuban troops in neighboring Angola are withdrawn.

Washington, which also wants the Cubans out, is backing South Africa in this. African states in the region back Angola's view that the Cubans are needed for protection against South African raids into Angola in pursuit of SWAPO forces. Angola says that the issue is one of its own sovereignty and that the two questions should not be linked.

Part of the U.S. attempt to break the deadlock has been Vice President Bush's current seven-nation African trip, during which he has tried, apparently with little success, to persuade African leaders that the Cubans should be removed.