A treaty signed last week between the Soviet Union and Mozambique clearly leaves open the possibility of Soviet military assistance to the southern African nation in case of an attack from white-ruled South Africa or Rhodesia, according to the text published today.

The document should bolster considerably Mozambique's presently weak diplomatic and military position with both Rhodesia and South Africa. For the past eight months, it has been undergoing deep Rhodesian incursions as the result of the white-minority government's spreading war with nationalist guerrillas.

At the least, the friendship treaty means that both South African and Rhodesian leaders will have to take into their calculations the possibility of direct Soviet involvement in the defense of Mozambican borders and African nationalist guerrillas camps inside Mozambique.

The treaty states that "in the case of situations tending to threaten or disturb the peace," the two countries "will enter into immediate contact with the aim of coordinating their positions in the interest of eliminating the threat or reestablishing peace."

Another section of the treaty says the two countries will continue to develop their cooperation in the military sphere "on the basis of the relevant agreements signed by them in the interest of strengthening their defense capacity."

The two articles seem to imply that the Soviet Union would be willing to come to the defense of Mozambique if it were seriously threatened by either South Africa or Rhodesia, although there is no clear Soviet commitment.

The treaty thus discloses that the Soviet Union had already signed several military agreements with Mozambique.It was known that substantial quantities of Soviet arms are already beginning to arrive in northern Mozambican ports.

This pact is believed to be similar to one signed by the Soviets with Angola, except that it was signed by the governments and not parties. It was signed last Thursday in the Mozambican capital of Maputo between visiting President Nikolai Podgorny and Mozambique leader Samora Machel. Like those signed earlier with Somalia and Angola, the only other black African nations to have such close formal ties with Moscow, the pact is for 20 years.

The treaty pledges to "develop cooperation, mutual aid and exchange of experiences" in science, culture, literature, education, health, journalism, tourism and sports.

In addition, it lists various economic sectors where the Soviet Union is to provide assistance, although there is no indication of amounts. Present Soviet aid outside the military field is limited to about 100 technicians and medical personnel, whose salaries are paid by Mozambique.

The two governments also agreed to expand cooperation between political and social organizations, presumably foremost among them their ruling parties. The Front for the Liberation of Mozambique has just declared itself a Marxist-Leninist party, a step that should greatly facilitate ties with the Soviet Communist Party.

The Soviet Union also committed itself to the African struggle against "the forces of imperialism for the final elimination of colonialism, neo-colonialism, racism and apartheid." The latter team refers to the South African system of strict racial separation.

The two nations are to cooperate in supporting the struggle of the African nationalists in Rhodesia, Namibia (Southwest Africa), and South Africa for "their freedom, independence and social progress." Podgorny stressed throughout his two-week trip in southern Africa his government's strong support for the African liberation movement.

[Podgorny arrived back in the Soviet Union Sunday, Reuter quoted the Soviet news agency Tass as reporting.]

The treaty contains a statement of Soviet respect for Mozambique's policy of nonalignment, which it describes as "an important factor for the maintenance of international peace and security." Both countries pledge respect of the other's sovereignty and promise not to interfere in each other's internal affairs.

In effect, the treaty spells out what Machel regards as "an exemplary relationship." He has been using this term in his speeches to describe his country's developing ties with Moscow since last May, when he visited the Soviet Union.

The most crucial aspect of this relationship in the immediate future will be Soviet military assistance to help Mozambique's defense against Rhodesian ground and air attacks and almost daily Rhodesian air reconnaisance incursions.

There has been no confirmation that the Soviets have provided a ground-to-air missile system, but such assistance is widely expected.

Soviet supplies for the African nationalist guerrillas in Rhodesia are now pouring into Mozambique's northern ports, apparently in preparation for a new offensive after the last one was disrupted by Rhodesian army incursions in November and December.