The Soviet Union has mounted a major counter-offensive to blunt a joint attempt by Western powers and the oil-rich conservative Arab states to sway this Indian Ocean country and neighboring South Yemen away from the Soviet orbit of influence.

But a serious malaise is developing between Mogadishu and Moscow over the Soviet decision to support and arm the Marxist military government in Ethiopia - Somalia's No. 1 enemy. This may yet drive a wedge between the two closely allied countries, according to Arab, Western and even Somali sources here.

"It all depends how far the Soviet Union goes in helping Ethiopia," remarked one Arab diplomat.

Arab and Western diplomatic sources report that Moscow has launced a drive here and in South Yemen, promising increased economic assistance and stepping up the number of Eastern bloc delegations visiting, particularly in South Yemen.

"They are very, very active throughout the region these days," the Arab diplomat said of the Soviets.

The main objectives of the current Soviet diplomatic campaign, in addition to maintaining its position here, are reported to include a peaceful settlement of the long-standing Somali-Ethopian territorial dispute over the Ogaden region; a resolution of the secessionist struggle raging in Ethiopia's northern Eritrea Province; and the establishment of a Soviet-blacked grouping of Marxist states at the southern end of the strategic Red Sea waterway.

In each case, the Soviet Union is thought to be proposing to its allies some kind of federation as a possible solution and means of engineering a Pax Sovietica throughout this conflict-ridden region to assure itself a dominant influence. So far, however, stubborn nationalism appears to be proving for stronger than the spirit of international Marxist brotherhood.

Meanwhile, the Arab oil states, with Saudi Arabia taking the lead, have held out the promise of rich financial rewards - including funds for the purchase of arms in the West just as they are doing for Egypt and Sudan - if Somalia breaks with the Soviet Union.

The figure of proffered Saudi aid mentioned most often in Arab circles here is $300 million to $350 million, although Saudi diplomats in the region say that this is a vastly exaggerated estimate of Somali needs. Last year Saudi Arabia gave Somalia $28 million; so far this year it has furnished another $16 to $18 million.

Now Saudi Arabia is said to be waiting to see whether the United States or some other Western country, such as France, will make an arms offer before ante raises its nate any further. The Saudis are also understood to be waiting for some concrete Somali gesture of an intention to lessen Somalia's dependence on the Soviet Union and move closer to the conservative Arab world before they increase their financial commitment.

So far, neither the United States nor any other Western power has signaled a willingness to take over from the Soviet Union the onerous task of supplying Somalia with arms and military assistance. Somalia's is probably the best-equipped army in black Africe, but keeping it running has required the presence of several thousand Soviet military advisers.

The initiative the Carter administration is about to take to improve relations with Somalia is reportedly limited to an initial offer of economic assistance that is still far less than the $100 million President Mohamed Siad Barre has indicated he would like from Washington.

Skepticism about America intentions has been made clear here by the Somali leader's dicision to ignore for more than two weeks a request by U.S. Ambassador John L. Loughran to meet with him to discuss Washington's offer.

Thus, despite mounting tensions in Soviet-Somali relations, there is no indication so far that the Somali leader is about to follow the example of Egypt and Sudan and end his close alliance with the Soviet Union. Indeed, it appears that he simply cannot afford to do so in the absense of any certain alternative source of arms.

Futhermore, he has told some correspondents who have recently talked with him in private that he is not going "to beg" for arms from the West as President Anwar Sadat of Egypt and President Jaafar Nimeri of the Sudan have been forced to do after cutting their military ties with the Soviet Union.

Nonetheless, reports circulating here in diplomatic circles say that one of the main purposes of the visit to Peking by Somali Vice President Ismail Ali Abocar next month will be to explore with Chinese leaders the possibility of obtaining spare parts for Soviet arms. Chinese diplomats here have alrady let it be known that Peking is ready and willing to help.

In the past, China has provided some spare parts for Migs and other Soviet equipment given to Egypt and Sudan, although it has apparently not had the desire or capacity to replace the Soviet Union as their main arms supplier.

It appears from the number of Western correspondents suddenly being allowed, and even encouraged, to visit here that President Said Barre is also interested in improving his relations with the West.

Thus the outcome of the current diplomats tug of war over Somalia between the Soviet Union and pro-Western Arab states is still uncertain. What is clear, however, is that a major bone of contention now exists in Somali-Soviet relations and that the Somalis can no longer count on Moscow to support them in their feud with Ethiopia.

Somali officials do not hide their bitterness and deep disillusionment over the Soviet decision to become Ethiopia's principal big-power ally at the probable expense of Somali claims to the Ethiopian Ogaden region. There are even unconfirmed reports here that several Soviet advisers in a position to know all about Somali military plans have recently been transferred to Addis Ababa.

"The Soviets think that the Ethiopian revolution is more Marxist and 'genuine' than ours, but we don't agree," said one Somali official.

President Siad Barre more than made this clear at his press conference with 20 Western and Arab journalists 10 days ago, when he remarked curtly that "bloodshed, torture and killing" currently under way in Ethopia was not socialism in his view but simply a struggle for power.

The Soviets have been trying to placate the Somalis by offering to increase their economic assistance and to begin immediately several projects they were scheduled to undertake in the next five-year plan they are now preparing for the Somali government.

But Arab sources here say that the Somalis turned the Soviet offer down, partly to show their displeasure over Moscow's new pro-Ethiopian tilt and partly because they are not altogether happy with the way the Soviet economic aid program is being carried out. In particular, there have been long delays in the construction of the $27 million dam at Fanole in southern Somalia, the major Soviet economic-aid project in the country.

In South Yemen, the Soviet Union has been working actively to prevent a pro-Arab faction in the Marxist government there from gaining the upper hand over the pro-Soviet one, according to Western diplomats who have recently returned from there.

But contrary to some Western press reports, South Yemen does not seem to have "gone over" to the conservative Arab camp. The South Yemenis have followed Soviet Policy toward the Ethiopian military regime and are cooperating with Moscow in its attempt to bolster the Addis Ababa government.

The first 30 Soviet tanks to arrive in Ethiopia came from Soviet stocks in Aden, and South Yemen has provided about 40 Soviet-trained tank instructors to teach the Ethiopians how to use them.

In addition, South Yemen is the only Arab country in the Red Sea region to have ceased its support for the Eritrean Liberation Front, the group leading the struggle for the independence of Ethiopia's northermost province. The one other Arab country supporting the Ethiopian Marxist military government is Libya, another Soviet ally.

The Soviet Union has been encouraging Libya and South Yemen to act as go-betweens in its efforts to resolve the Eritrean conflict. The Soviets are now actively promoting a dialogue between the Marxist faction of the Eritrean nationalist movement, the Eritrean People's Liberation Front, and the Ethiopian military government in an effort to arrange for a federation that would keep Eritrea part of Ethiopia.

Last week Soviet diplomats held talks here with one of the Front's top leaders while another was in Tripoli meeting with Libyan officials to discuss a possible federal solution. The outcome of these contacts was not immediately known, but in the past all factions of the Eritrean movement has totally rejected proposals for a federation.

There are no signs either that the Soviet effort to resolve the Somali-Ethiopian territorial dispute over the Ogaden is having any success so far. President Siad Barre said at his press conference that his meeting in March with Ethiopia's military strongman, Col. Mengistu HaileMariam, in Aden had produced no agreement.