MOSCOW, DEC. 27 -- The Soviet Union registered a strong protest with Iran over an attack today by Afghan demonstrators on the Soviet consulate in the central Iranian city of Isfahan, the Soviet news agency Tass reported.

Tass said the Iranian Foreign Ministry expressed regret over the incident, which it attributed to Afghan emigrants who oppose the Iranian leadership's efforts to develop relations with its northern neighbor. The official Iranian news agency described the attack as a protest by Afghans in Isfahan at the eighth anniversary of Soviet military intervention in Afghanistan.

According to the Tass account, a band of "rampaging thugs . . . invaded the territory of the Soviet mission," endangering the lives of Soviet citizens. It said the attackers were repelled by Iranian police using firearms. A number of demonstrators and policemen were injured, Tass reported.

Tass said no Soviets were injured "thanks to a lucky chance," although the building was damaged. It said Iran increased police protection around the consulate after receiving the Soviet protest, which was delivered both in Moscow and in Tehran. The Soviets demanded assurances that the incident would not be repeated and asked for compensation for damages, Tass said.

The presence of Afghan refugees in Iran, who are roughly estimated at about 1 million, and the support given to Afghan rebels by the Khomeini regime have been a major sore point in Soviet-Iranian relations. Still, Tehran has improved ties with its northern neighbor in the last year, and the quick handling of today's incident suggests Iran wants to isolate its relationship with Moscow from its backing of the Afghan rebels.

Increasingly isolated from the West, Iran has put greater stock in its relations with the Soviet Union. The two countries have revived economic projects, including the shipping of Iranian natural gas through the Soviet Union and the completion of a railway line into Soviet central Asia.

Earlier this year, Moscow signaled the improvement in relations by dispatching several high-level delegations to Tehran and positioning itself as a potential mediator in the Iran-Iraq war.

Recently, however, Moscow has indicated it will back a United Nations resolution to impose sanctions against Iran, a move which would sour bilateral ties.

A recent dispatch by Tass, published in an Armenian newspaper, delivered a scathing attack on Iranian leader Ayatollah Ruhollah Khomeini, describing him as a fanatical figure who has neglected the needs of his own population.

The Associated Press reported:

Afghan refugees protested around the world at the eighth anniversary of the Soviet intervention in Afghanistan. The Soviet Union ignored the anniversary as protesters marched in Pakistan, Britain, France and West Germany.

Thousands of Afghans who have fled to neighboring Pakistan to escape the war chanted "Death to Russia!" and burned effigies of Soviet leader Mikhail Gorbachev at rallies in Islamabad and Peshawar. Demonstrators in the Bangladeshi capital, Dhaka, stoned the Soviet cultural center in a brief but turbulent protest and fled when police rushed to the scene, witnesses said. Other protests were reported in the Netherlands and India.

On Dec. 27, 1979, the Soviet Union installed a Soviet-backed government in Kabul, after airlifting 4,000-5,000 troops to the capital on Dec. 25-26.

President Reagan marked the day by urging the Soviet Union to "promptly and irrevocably" withdraw the estimated 115,000 troops it has backing the Kabul government against anticommunist guerrillas. West Germany's two biggest political parties echoed the call.

{In Washington, about 100 Afghans demonstrated, carrying hand-lettered placards saying "Russia is the Devil" and "Down with Soviet Imperialism." They gathered at 16th and K Streets NW, the closest police would allow them to the Soviet Embassy a block and a half to the north. The gathering ended peacefully.}