President Reagan, attempting to escalate pressure on the Sandinista government of Nicaragua, charged yesterday that a "new danger" in Central America "is the support being given the Sandinistas" by the Iranian regime of the Ayatollah Ruhollah Khomeini, as well as by Libya and the Palestine Liberation Organization (PLO).

Reagan's remarks in a speech to legislators from other nations marked the first time he has accused Iran of supporting the Sandinistas and came as Iranian Prime Minister Mir Hossein Mousavi visited Nicaragua and met with President Daniel Ortega. Earlier, he had visited Cuba.

Sources said the United States believes that the Iranian official is the "kingpin in the Iranian terrorist operation" and may be seeking to introduce to Central America terrorist activities used in the Middle East. One source cited the suicide truck bombings in Lebanon as the type of activities that may be involved.

"We've seen terrorism in this hemisphere, but nothing like that in the Middle East," one informed source said. "The potential for that kind of terrorism in this hemisphere is very troubling."

Administration sources also said the Iranian official is expected to be discussing a possible oil deal between Nicaragua and Iran that would reduce the need for Nicaragua to buy oil from Mexico and the Soviet Union. The Iranian official may also be discussing arms shipments to the Sandinistas, one administration official said.

The official said that the United States has intelligence information that Iranian Embassy officials in Managua have had contacts with Colombia's M-19 guerrillas and that a radical faction of the PLO has provided training and acted as advisers to the Sandinistas. "We have data that a number of terrorist groups have trained and found safe haven in Nicaragua," the official said.

Speaking to delegates at the Western Hemisphere Legislative Leaders Forum, Reagan also said that aiding the "freedom fighters," or contras, opposing the Sandinistas is "essentially acting in self-defense" by the United States and its allies.

The administration made this argument recently in contending that the International Court of Justice did not have jurisdiction over U.S. actions in Central America, but yesterday marked the first time Reagan has used it in a policy speech on the subject.

Reagan's comments came the day after incoming Senate Foreign Relations Committee Chairman Sen. Richard G. Lugar (R-Ind.) said that aid to the contras, which Congress halted last year, is no longer "viable."

Reagan is expected to seek a revival of the aid program this spring, however.

"The transition to democracy, especially in Central America, has been accompanied by a concerted and well-financed effort by the Soviet bloc and Cuba to undermine democratic institutions and to seize power from those who believe in democracy," Reagan said. "The subversion we're talking about violates international law; the Organization of American States, in the past, has enacted sanctions against Cuba for such aggression.

"The Sandinistas have been attacking their neighbors through armed subversion since August of 1979," Reagan said, adding that the U.S. program of support for the "freedom fighters" is in self-defense and is consistent with the United Nations and OAS charter provisions for "individual and collective security."

White House spokesman Larry Speakes said Reagan's charge about "support" from Iran was based on "other factors" besides the prime minister's visit to Managua, but would not be specific.

Reagan unexpectedly brought up policy toward Libya in a White House meeting yesterday morning with visiting Italian Defense Minister Giovanni Spadolini.

Diplomatic sources quoted Spadolini, whose country has extensive experience in and ties with Libya, as telling Reagan that a policy of "excommunication" of Libya has outlived its usefulness and that the time is ripe for renewing communications with Libya leader Muammar Qaddafi.