The Soviet Union has a deep and abiding concern over the future of its relations with neighboring Iran resulting from the shah's departure, press commentaries and other official views expressed here indicate.

Although Moscow is cheered by the prospect of a sharp decline in American influence, the Soviets at the same time show unmistakable sings that they are worried by the upheaval in Iran for a variety of reasons.

These range from the disruption of Iranian natural gas deliveries to the southern areas of the Soviet Union to long-term problems the establishment of a militant Moslem government in Tehran might create in the overwhelming Moslem population in the TransCaucasus and Soviet Central Asia.

With an estimated 50 million Moslems along its Asian and TransCaucasus borders, the Soviet Union is the world's fifth largest Moslem country. The shah, who had a long and generally successful relationship with Moscow, had not attempted to influence Moslems in the Soviet Union.

The shah's principal opponent, Ayatollah Ruhollah Khomeini, is a fundamentalist Moslem Shiite leader whose policies could create difficulties for the Soviets should he attempt to involve Soviet Moslems in the current revival of traditionalist Islamic values.

A Khomeini spokesman said last week that a government appointed by Khomeini would "propagate the depth and dimensions" of the Shiite Iranian movenent into Soviet territory. There are more than 4.5 million Shiite Moslems in Soviet Azerbaijan, who have close ethnic, cultural and even family ties with about 4 million Iranian Azerbaijans.

Unconfirmed reports circulating here suggest that Soviet authorities have moved some Azerbaijani communities back from the Soviet-Iranian border in recent weeks. There are also reports, which could not be confirmed, that Soviet forces in the border area have been on an "alert" status since early November.

Despite the potential problems, the Soviet press in recent days has focused on what it sees as Soviet gains emerging from the turmoil in Iran.

In this view, radical alteration of Iranian politics and foreign policy along even more sharply nationalistic lines promises certain Soviet gains throughout the oil-producing Middle East. An Iran preoccupied with its own internal problems and hamstrung or unwilling to pursue a pro-Western foreign policy cannot stand as a bulwark against communist expansionism from the north.

The United States can be seen as having been dealt a setback by the turmoil that has driven its strongest regional ally into temporary -- and perhaps permanent -- exile. American inability to preserve his direct rule has shaken the U.S. image among pro-Western Arab states whose oil helps fuel the West.

Pravda, the Communist Party daily, today asserted with an optimistic note that "Iranians of different views, different religious and political orientation, speak in favor of refusal from a one-sided pro-American foreign policy, liquidation of American military bases. Ending oil export to Israel and South Africa, carrying out the policy of nonalignment, and support of fair struggle of the Arab nations against Zionist aggression."

Commentator P. Demchenko told with relish how the monarch who once used Iranian military power to aid the sultan of Oman against leftist rebels in Dhofar Province spent his first days out of power with Egyptian President Anwar Sadat, who is reviled here for his peace talks with Israel.

The Pravda article spoke at length about Iranian social dislocations, military spending and reported corruption of the shah and his advisers, which it said made the drive for change inevitable. It continued the strident propaganda attack on the U.S. efforts first to shore up the shah and most recently to seek backing for the shaky new government of Prime Minister Shahpour Bakhtiar.

Iran is a principal Third World trading partner of the Soviet Union, and before the turmoil shut down oil and gas production, the Soviets imported about 10 billion cubic meters of matural gas annually for its three TransCaucasian republics. Severe heating problems now have hit Armenia, Georgia and Azerbijan because of cessation of Iranian pumping.

While praising Khomeini as a sincere leader and a genuine man of the people, the Soviets have not gone so far as to overtly back him. Although calling the shah's government discredited and unpopular, Soviet propaganda has not fastened as yet on the ayatollah as the man of the coming moment. Pravda, for example, in its commentary today, asserted that "the striking peculiarity of the (antishah) movement, despite the absence of a unigue center, is its newly allpopular nature."

Perhaps reflecting traditional Soviet unease at strong religious leaders, Pravda asserted that there is "nothing unexpected" about religious leaders heading the struggle against the shah. Iran's peculiarity lies in the fact that most of its population is connected with traditions of Shiism, which carries a progressive nature."

One Arab observer here asserted that the gingerly Soviet approach to the question of the shah's eventual successor and Khomeini himself reflects Kremlin worries that "the future may hold more influences from Iran into the Soviet Union than the other way around."