Something has gone wrong with the Reagan Doctrine in southern Africa, one of the regions where the administration has labored hardest to outmanuver and limit Soviet influence: Moscow, aided by the rightward lurch in Washington's foreign policy and by South Africa's low-grade but persistent war against its black neighbors, is quietly staging a diplomatic comeback.

Only two years ago, with the signing of the Nkomati Accord between South Africa and Marxist-oriented Mozambique, formerly a close Soviet ally, Moscow was seen as having lost of one its few footholds in the region. On the continent as a whole -- from Guinea to Somalia, Egypt to Mozambique -- the African landscape was littered with enough tales of Soviet arrogance and ineptitude to make the comrades from Moscow seem like the Gang That Couldn't Shoot Straight.

But the tables may be turning. Under the leadership of Mikhail Gorbachev, Moscow is beginning to win new friends and influence nations less by making new commitments or taking risks than by adopting a more flexible and conciliatory approach to black governments in the region.

In this effort, analysts from both East and West agree, Moscow has been helped immeasurably by South Africa's inability to keep its hands off its neighbors. Last week's commando raids on Botswana, Zimbabwe and Zambia -- spectacular displays of fireworks that did virtually no damage to the rebels they supposedly were aimed at -- have reinforced the longstanding impression that Pretoria has inadvertently become Moscow's best helpmate in Africa.

Gorbachev has also received a helping hand from the Reagan administration, which is widely perceived here as having been caught up in its own aggressive rhetoric in recent months. On issues as diverse as U.S. military aid to Jonas Savimbi's rebel movement in Angola, last week's bombing of Libya and nuclear disarmament, Washington is increasingly viewed as war-like and irrational, Moscow as peace-loving and reasonable.

Since its inception, the Reagan administration has tended to judge its success in the region in East-West terms. Ironically, it is precisely in those terms that Washington now is seen to be stumbling.

"The Soviet Union is doing better," said a senior Western European diplomat here, "and to be brutally frank, the reason they're doing better is because of the counter-productive nature of U.S. policy. They are the passive beneficiaries of your mistakes."

In Angola, Moscow has cemented its ties with the Marxist-oriented government and reversed a process by which a significant faction inside the ruling party appeared to be reaching out to the West. The key to its success has been Angolan anger over U.S. support for Savimbi and fears that Washington has decided to join with Pretoria, which also supports Savimbi's rebels, in seeking to overthrow the Luanda regime. The Reagan administration clearly regards closer Soviet-Angolan ties as an acceptable risk.

With Mozambique, the Soviet Union has managed to maintain close relations and recently hosted President Samora Machel in Moscow despite deep Soviet disappointment in the Machel government's 1984 pact with Pretoria. It is also capitalizing on Mozambican fears that the CIA may reverse U.S. policy by throwing its support behind antigovernment rebels, who have received South African backing as well.

In South Africa itself, the Soviet Union is held in esteem by many blacks as an ally and strong supporter of the outlawed African National Congress, the main black resistance movement. Red flags and anti-American rhetoric with a strong Marxist tinge have become regular features at funerals for black victims of civil unrest.

But it is Zimbabwe, whose leaders traditionally have been cold toward the Soviet Union, that best illustrates the modest but significant new success Moscow is achieving in the region.

That success is a blend of several factors: heightened fear of South Africa aggression and the perception that the West will do little or nothing in Zimbabwe's defense if Pretoria chooses to attack; anger and suspicion over U.S. aid to Savimbi, and Gorbachev's success in establishing a personal rapport with Mugabe, a fiercely independent leader who, despite his personal commitment to socialism, has until now been immune to Soviet charms.

Moscow backed the wrong horse in the liberation struggle against white minority rule here. Its exclusive support for guerrilla leader Joshua Nkomo alienated Mugabe's rival movement. When Mugabe won Zimbabwe's first national election and the premiership in 1980, the Soviets were frozen out.

But there were other factors behind western ascendancy here, as political scientist Michael Clough pointed out in a recent article for the Center for Strategic and International Studies' "Africa Notes." The United States and Britain had far more capital and expertise to contribute to Mugabe's new country and their diplomatic leverage over Pretoria appeared to him a more likely deterent to South African intervention than Soviet arms.

None of these would have been decisive, says Clough, had not Mugabe also believed he could trust the West. But that trust has been drained away in recent months.

The main reason is South Africa. As black unrest has intensified during the past year Pretoria has been increasingly inclined to lash out at its black neighbors, contending that they harbor "terrorists" fomenting strife. Both Botswana and Lesotho -- moderate, pro-western states -- have been the target of South African commando raids and Lesotho's government was overthrown in January in a South African-supported coup. Now Zimbabwe and Zambia been added to the list of countries whose borders and sovereignty Pretoria feels compelled to violate

Those events have sent a wave of fear through the fragile black governments of the region. They have started searching for powerful friends to protect them from Pretoria -- but have found little comfort in the West.

Zimbabwe has sought unsuccessfully to interest the West, especially the British, in supplying more sophisticated aircraft and air defense missiles to defend against a South African attack. But western diplomats fear such systems would only escalate regional tensions and provoke the South Africans into an Israeli-style preemptive strike. The result has disappointed the Zimbabweans and raised doubts about the West's commitment here.

"We learned from Botswana," said a Zimbabwean government source, referring to last June's South African commando raid on suspected black guerrillas there. "You couldn't find a more pro-western government and look what happened there. The British and the Americans are constantly telling us what limited influence they have on South Africa. We've never accepted that, but we realize that if anything happens to us, that's the way they'll play it."

In the tense atmosphere created by South African militarism, the newly enunciated Reagan Doctrine of support for anticommunist "freedom fighters" has had the effect of a lighted match in a bomb factory. Nervous black governments fear that if Washington can support Savimbi's South African-backed rebels against the internationally recognized government of Angola, what will stop it from doing the same thing in places like Mozambique and Zimbabwe, each of which also face Pretoria-supported insurgencies?

"We observe a common purpose between South Africa and the U.S. in the sub-region," said Zimbabwean Minister of State Security Emmerson Munangagwa, generally considered a political moderate, in a recent speech in which he accused Washingtin of joining with Pretoria in destabilizing the region.

Washington's denials of collusion with Pretoria ring so hollow here that even American diplomats have begun to have doubts. When a Zimbabwean cabinet minister recently accused the United States of funding clandestine anti-Zimbabwe radio broadcasts from several factors: heightened fear of South Africa aggression and the perception that the West will do little or nothing in Zimbabwe's defense if Pretoria chooses to attack; anger and suspicion over U.S. aid to Savimbi, and Gorbachev's success in establishing a personal rapport with Mugabe, a fiercely independent leader who, despite his personal commitment to socialism, has until now been immune to Soviet charms.

Moscow backed the wrong horse in the liberation struggle against white minority rule here. Its exclusive support for guerrilla leader Joshua Nkomo alienated Mugabe's rival movement. When Mugabe won Zimbabwe's first national election and the premiership in 1980, the Soviets were frozen out.

But there were other factors behind western ascendancy here, as political scientist Michael Clough pointed out in a recent article for the Center for Strategic and International Studies' "Africa Notes." The United States and Britain had far more capital and expertise to contribute to Mugabe's new country and their diplomatic leverage over Pretoria appeared to him a more likely deterent to South African intervention than Soviet arms.

None of these would have been decisive, says Clough, had not Mugabe also believed he could trust the West. But that trust has been drained away in recent months.

The main reason is South Africa. As black unrest has intensified during the past year Pretoria has been increasingly inclined to lash out at its black neighbors, contending that they harbor "terrorists" fomenting strife. Both Botswana and Lesotho -- moderate, pro-western states -- have been the target of South African commando raids and Lesotho's government was overthrown in January in a South African-supported coup. Now Zimbabwe and Zambia been added to the list of countries whose borders and sovereignty Pretoria feels compelled to violate

Those events have sent a wave of fear through the fragile black governments of the region. They have started searching for powerful friends to protect them from Pretoria -- but have found little comfort in the West.

Zimbabwe has sought unsuccessfully to interest the West, especially the British, in supplying more sophisticated aircraft and air defense missiles to defend against a South African attack. But western diplomats fear such systems would only escalate regional tensions and provoke the South Africans into an Israeli-style preemptive strike. The result has disappointed the Zimbabweans and raised doubts about the West's commitment here.

"We learned from Botswana," said a Zimbabwean government source, referring to last June's South African commando raid on suspected black guerrillas there. "You couldn't find a more pro-western government and look what happened there. The British and the Americans are constantly telling us what limited influence they have on South Africa. We've never accepted that, but we realize that if anything happens to us, that's the way they'll play it."

In the tense atmosphere created by South African militarism, the newly enunciated Reagan Doctrine of support for anticommunist "freedom fighters" has had the effect of a lighted match in a bomb factory. Nervous black governments fear that if Washington can support Savimbi's South African-backed rebels against the internationally recognized government of Angola, what will stop it from doing the same thing in places like Mozambique and Zimbabwe, each of which also face Pretoria-supported insurgencies?

"We observe a common purpose between South Africa and the U.S. in the sub-region," said Zimbabwean Minister of State Security Emmerson Munangagwa, generally considered a political moderate, in a recent speech in which he accused Washingtin of joining with Pretoria in destabilizing the region.

Washington's denials of collusion with Pretoria ring so hollow here that even American diplomats have begun to have doubts. When a Zimbabwean cabinet minister recently accused the United States of funding clandestine anti-Zimbabwe radio broadcasts from South Africa, the U.S. embassy here waited 24 hours before denying the charge. Diplomats explained they were waiting for a firm denial from Washington because, as one put it, "these days you never know what the CIA may be up to."

All of this has helped give the Soviets the opening they have long sought here -- as was best illustrated in December following a series of landmine explosions inside South Africa near the northern border town of Messina. Pretoria blamed the attacks on black guerrillas it said were operating from Zimbabwe and warned Harare that South Africa might send its troops over the border in hot pursuit.

The warning came just as Mugabe was leaving for his first official visit to Moscow since independence. There he was given the red carpet treatment, including a three-and-one-half hour private session with Gorbachev the length and warmth of which surprised both leaders' closest advisers.

Mugabe returned home saying that as a result of the visit, "we are very much closer in our ideas, in the rapport that we have created and in our assessment of international issues." He also said he and Gorbachev had discussed "how we can strengthen ourselves in the face of threats from South Africa."

Since then, Mugabe's defense minister has made a second visit to Moscow to discuss military assistance and Soviet military officials have quietly visited Zimbabwe as part of a Soviet trade delegation.

Zimbabwe is said to be considering the purchase of a Soviet-made air defense system that would include surface-to-air missiles. There is also speculation that Mugabe may ask Moscow to outfit with sophisticated electronics a set of aging MIG 21s that Zimbabwe has purchased from China.

Senior Zimbabwean army and air force officers, who were trained on British equipment and weaned on British military strategy and tactics, have resisted turning to the Soviets, sources here say; and they believe Mugabe himself vetoed a Soviet proposal to sell Zimbabwe highly sophisticated MIG 25 fighters in part because they would have been accompanied by Soviet and East European instructors.

Nonetheless, a closer relationship is inevitable, according to Zimbabwean officials. As one put it, "The Soviet strategy is not lost on us -- we're aware of their motives -- but we need to defend ourselves and we'll take help wherever we can get it."

The Soviets themselves harbor few illusions that their new relationship with Zimbabwe is anything but tentative. "We have learned to be patient and to lower our expectations," said a Soviet analyst here, speaking not for attribution. "We think Mugabe has finally come to the conclusion that he needs the Soviet Union more than the Soviet Union needs him, but we don't expect anything dramatic to happen here."

Soviet patience has been born in large part through previous disappointments, the analyst said. In the 1960s, Moscow was obsessed with enrolling African states into the Marxist camp and taken in by their socialist rhetoric. But a series of defections -- including the expulsion of Soviet advisors from Egypt and Somalia's jumping to the West -- have taught the Soviets a bitter lesson.

Soviet gestures towards longstanding friends like Angola, potential friends like Zimbabwe and estranged friends like Mozambique are designed to send a clear message to other African states that Moscow's policy in Africa, unlike Washington's, is consistent, patient and friendly. It is calculated to capitalize on American shortcomings, South African militarism and African fears.

"The United States is repeating the same mistakes that we made 20 years ago," said the Soviet analyst. "You are concentrating too much on ideological surfaces and ignoring much more important things. You are losing influence and you have no one to blame but yourselves."