WASHINGTON (AP) _ Last week's visit to Iran by a senior Soviet delegation has reinforced U.S. fears of closer ties between Tehran and Moscow, even though Iranian leaders made clear their distrust of the Kremlin.

American officials, eyeing Iran's long northern border with the Soviet Union and key location along Gulf oil routes, have long been haunted by the specter of greater Russian influence, and possible control, in Iran.

''We are watching and listening,'' said one State Department official, noting that although Iran and the Soviets were talking about expanding trade, Iranian officials used the occasion to denounce Moscow for sending troops to Afghanistan and arms to Iraq, the two nations that flank Iran.

The trade discussions appeared to be part of a wider effort by Iranian officials to rebuild bridges that were cut with other countries after the 1979 revolution, said Khosrow Shakeri, an Iranian scholar at the Kennan Center for Advanced Russian Studies in Washington.

U.S. officials agreed, casting the Soviet visit as a step rather than a leap in slowly improving Iranian-Soviet relations.

''It's part a continuation of Iran's efforts to normalize relations with other nations,'' said a U.S. analyst who spoke on condition of anonymity.

The head of the Soviet State Committee for Foreign Economic Relations, Konstantin F. Katushev, won an agreement to export to Iran equipment for mining, steel and aluminum producion, but left without an awaited agreement to boost the sale of Iranian natural gas to the Soviet Union.

Iran needs the money to replace revenue lost from falling oil prices and production, and to pay for its war with Iraq, a Soviet client state.

Relations between Tehran and Moscow worsened after the Iranian revolution and the Soviet invasion of Afghanistan in 1979.

Many leaders of Iran's Tudeh Party, a communist group linked to Moscow, are in jail or exile, many other pro-Soviet military officers have been purged, and in 1984 the Iranian government expelled 16 Soviet diplomats on charges of spying. The Kremlin was also forced to withdraw technical experts from Iran and shut consulates outside Tehran.

Katushev's mission, officially the 10th ministerial meeting of the Permanent Commission for Soviet-Iranian Cooperation, was originally scheduled in 1980 but was delayed for six years because of bilateral friction.

The Soviet Union maintains an embassy in Tehran, in contrast to the United States, which severed diplomatic and trade ties after Iranian militants seized the U.S. Embassy on Nov. 4, 1979, and held 52 Americans hostage.

Reflecting long-standing American concern about Soviet influence in Iran, President Reagan, in a speech on Nov. 13 justifying his sale of arms to that country, said: ''Geography explains why the Soviet Union has sent an army into Afghanistan ... and, if they could, Iran and Pakistan.''

Russia has long had terroritorial ambitions in Iran, gobbling up bits of land along the Caspian Sea in the 19th century and occupying the northern half of the nation during World War II, while Britain occupied the south.

After the war, the Soviet Union established a short-lived client state in what is now Iranian Azerbaijan, and bitter feelings linger.

The American fear is that Iran may become chaotic when revolutionary leader Ayayollah Ruhollah Khomeini dies, and the nation - to borrow a phrase from the late Soviet leader Nikita Khrushchev - will fall like a ripe pear into the Soviet yard.

Iranian leaders are clearly aware of the danger.

Foreign Minister Ali Akbar Velayati told Katushev that the presence of Soviet troops was ''detrimental to the interests of the region'' and should be withdraw.

The Iranian president, Ali Khameni, said that ''the issue of Afghanistan can only be settled once an independent and popular government comes to power in Afghanistan.''

The speaker of the Iranian parliament, Hojatoeslam Hashemi Rafsanjani, had the harshest words for Moscow, assailing it for being the main supplier of arms to Iraq, with which Iran has been at war since September 1980. Rafsanjani is believed to have been a driving force behind Iranian overtures for U.S. arms.

''How can Moscow help the Iraqi regime deal blows on the anti-imperialist revolution of Iran while it sees the Baghdad government openly violates international conventions?'' Rafsanjani asked Katushev.

Rafsanjani, Khameni and Velayati balanced their criticism with optimism, stressing the importance they place on improving ties with Moscow, which they once lumped with the United States as the Great Satan.