President Reagan yesterday accused Iran, Libya, North Korea, Cuba and Nicaragua of forming an international terrorist network that he compared to "Murder Inc." and vowed that the United States would act "unilaterally, if necessary, to ensure that terrorists have no sanctuary anywhere."

"These terrorist states are now engaged in acts of war against the government and people of the United States," Reagan said in a speech to the American Bar Association. "And under international law, any state which is the victim of acts of war has the right to defend itself."

The president did not specify action he intends to take against such nations or terrorism other than to repeat last week's declaration by Secretary of State George P. Shultz that Beirut International Airport "must be made safe" or closed.

Reagan's list of terrorist nations conspicuously omitted Syria, a favorite target of U.S. denunciations of state-supported terrorism in the past.

Administration officials said the president appreciates Syrian President Hafez Assad's role in obtaining release of hostages from Trans World Airlines Flight 847 and hopes for his help in freeing seven Americans kidnaped in Lebanon since March 1984.

Reagan told applauding ABA delegates that Americans "are not . . . going to tolerate intimidation, terror and outright acts of war against this nation and its people.

"And we are especially not going to tolerate these attacks from outlaw states run by the strangest collection of misfits, looney tunes and squalid criminals since the advent of the Third Reich," he said.

Reagan's compilation of "outlaw governments" he blamed for international terrorism differs from the State Department's official list of countries that have made "the most significant contributions" to exporting terrorism.

State's list of terrorist nations includes Syria, South Yemen, Iran, Libya and Cuba but not North Korea or Nicaragua.

Edward P. Djerejian, White House deputy press secretary for foreign affairs, said, "There's no definite connection between the president's statements and what happens to be our basic list." Later, he said the United States is not supplying military weaponry to any of the seven countries, which he said was the basic reason for the terrorism list.

White House spokesman Larry Speakes, asked why Reagan did not mention Syria, said, "This is not an all-inclusive list of countries that are involved in terrorism, but it is an example of some of the most recent occurrences."

The inclusion of Iran on Reagan's list came despite reports that the Iranians had been helpful in obtaining the release of the 39 Americans held hostage in Beirut.

Reagan compared the five nations to pirates of an earlier era and said, "There can be no place on Earth left where it is safe for these monsters to rest, or train or practice their cruel and deadly skills."

The president also was sharply critical of Soviet statements during the hostage crisis. Reagan, scheduled to meet Soviet leader Mikhail Gorbachev for the first time in November at Geneva, cited Soviet assertions that the United States has been in the grip of "hysteria" that it had sought to use as a pretext for military action.

"Now, ladies and gentlemen of the American Bar, there is a non-Soviet word for that kind of talk, an extremely useful, time-tested original American word, one with deep roots in our rich agricultural and farming tradition," Reagan said to laughter and applause from the delegates.

The audience in Constitution Hall gave the president a standing ovation during a particularly emotional passage of his speech when he said Americans are united in the face of terrorism and added, "Let me say simply, we are Americans. We love this country. We love what she stands for, and we will always defend her."

Since the TWA hijacking June 14, Reagan has been under fire from conservatives who counted on him to carry out his 1981 promise of "swift and effective retribution" if Americans were taken hostage again.

The lead story in this week's Human Events, one of Reagan's favorite publications, was headlined, "Syria Emerges as Big Winner in Hostage Episode."

"The president may have had no other choice than to beg Assad for release of the Americans, but, by so doing, the president found himself in the unenviable position of enormously elevating the prestige of a champion supporter of terrorism, a bitter enemy of the West and a key force for destabilizing the entire Middle East," the article said.

Reagan was especially critical yesterday of one of his favorite targets, Nicaragua, asserting that its Sandinista leaders are harboring some of the "world's most vicious terrorist groups," including gangs from West Germany, Italy, Spain, Ireland and the Palestine Liberation Organization.

He also blamed them for sponsoring terror in Central America that, among other things, led to the shooting attack outside a Salvadoran restaurant in which four U.S. Marines and nine civilians were killed last month.

Speakes said Reagan was making a general charge against the Sandinistas for encouraging terrorism in the region rather than blaming Nicaragua for launching this specific attack.