The announcement yesterday that Algeria would serve as Iran's intermediary with Washington in the effort to conclude the hostage crisis spotlights a series of unusual developments that has unfolded in the last 18 months between this country and the Third World socialist government in Algiers.

These include a controversial visit to Algiers on Nov. 2, 1979 -- two days before the U.S. Embassy takeover -- by national security adviser Zbigniew Brzezinski and a mysterious visit to Algiers on Oct. 24, 1980 by Iranian Prime Minister Mohammed Ali Rajai shortly after leaving the United Nations in New York.

Though the United States did not choose Algeria to play the role of middleman, Tehran's choice came as no surprise to officials here.

Algeria is one of the few countries that has retained close ties to Iran throughout the hostage crisis and the more recent war with Iraq. At the same time, relations between Algiers and Washington have improved since President Chadhi Bendjedid took over in February 1979 after the death of the more radical and hard-line President Houari Boumediene.

Political relations with Algeria under Boumediene were bad for many years.

Algeria had granted safe haven for airplane hijackers and terrorists and its militant socialist leadership had encouraged various national liberation movements. Even in bad times, however, the two countries were able to keep their economic ties from suffering and those ties have grown even more important under the new government.

Algeria is a major importer of American technology and a major supplier of oil and natural gas to this country. In the first six months of this year, for example, the United States exported $315 million worth of goods to Algeria and imported $4.1 billion, mostly oil. Within the last year, Algerian military officers for the first time were invited to visit here and the government in Algiers expressed appreciation for prompt U.S. help in a devastating earthquake earlier this month.

In Paris, experienced Algeria-watchers believe that Algeria has been shrewdly trying to draw closer to the United States without alienating Moscow and saw the hostage issue as a good opportunity to do that. The Algerians are said to be privately unhappy over the Soviet invasion of Afghanistan.

In 1975, in what turned out to be a preliminary of the current Iran-Iraq war, Algeria played a key role as a mediator in trying to defuse more limited military confrontations between the two countries.

Last April, after President Carter expelled Iranian diplomats from this country, Tehran designated the Algerian Embassy in Washington to take care of Iranian affairs here.

Brzezinski's visit to Algiers in November 1979 may have been a factor in the improvement in relations between the United States and Algeria. But, ironically, it also may have been a factor in prompting the student militants in Tehran to launch their take-over of the U.S. Embassy.

Brzezinski went to Algiers as President Carter's emissary to ceremonies marking the 25th anniversary of Algeria's war of independence. Admnistration sources said yesterday that the move was meant as part of an effort to improve U.S. relations with the new Algerian regime and in northern Africa generally. These officials believe Brzezinski's visit was successful in that respect.

But while there, Brzezinski also met with a variety of other international leaders, including the Iranian Prime Minister Mehdi Bazargan and former foreign minister Ibrahim Yazdi. It was the first high-level discussion between U.S. and Iranian officials since Iran's revolution earlier in 1979 had ousted the shah from power. It also took place just as the shah was arriving in the United States.

In his recent book about the U.S. experience in Iran, called "Paved With Good Intentions," Barry Rubin says: "The Bazargan-Brzezinski meeting in Algiers was as influential in sparking the embassy takeover as was the shah's arrival in the United States."

After the embassy was seized, the United States took its case to the World Court in The Hague. Iran had retained an Algerian attorney to represent its interests there and officials said that episode marked the first time Algiers seemed to have some role as a go-between in the crisis. Officials said the Algerian was viewed as serious and responsible in his efforts and diplomatic sources said that Algeria had urged caution on the part of Tehran early in the hostage crisis.

Then last month, the Iranian prime minister, Rajai, stopped in Algeria on his way home from a surprise trip to the United Nations that was billed as an effort to condemn Iraq for its invasion but which also raised hopes that a solution to the hostage crisis was in the works. Though the visit was supposedly to express sorrow for the victims of a devastating earthquake, the stopover was shrouded in secrecy and a French-language magazine shortly afterward reported that Algeria would play a mediator's role in resolving the hostage situation.

There are also some hints of a change in the longstanding dispute between the United States and Algeria over American support of Morocco, which has been engaged in a lingering war in the western Sahara desert against Polisario guerrillas who are headquartered in Algeria.

Washington Post correspondent Ronald Koven reported from Paris yesterday that the Algerian government has put out some hints of responsiveness to Moroccan claims of some diplomatic progress in settlement of the dispute.