The U.S. Court of Appeals here ruled yesterday that the Carter administration can ban Iran-related demonstrations in Lafayette Square across from the White House while American hostages are being held in the U.S. Embassy in Tehran.

The ruling came shortly after government attorneys had told the court that demonstrators planning a protest today had been offered other sites, and could assemble either in McPherson Square or in Franklin Square -- several blocks from the White House.

The appeals court said in its three-sentence ruling that it "should accept the representation of the State Department that a demonstration at Lafayette Park has unacceptable potential for danger to the hostages now being held in the American Embassy in Tehran."

The 3-to-0 appellate ruling overturned a decision by U.S. District Judge Aubrey E. Robinson Jr. last Friday that said a more general ban on demonstrations concerning the Iran situation was unconstitutional. However, the government's arguments before the appealate panel focused more specifically on the proposed demonstration in Lafayette Square, and said it should be stopped because those holding the hostages might misinterpret the U.S. government's connection with the protest if the White House appeared in the background in news films or photographs.

The planned demonstrations is being supported by a group called "Students in Opposition to Violence," and is described by the group as a "march for peace between the United States and Iran."

American Civil Liberties Union attorneys, who brought the suit on behalf of the group, said they would not appeal yesterday's ruling and that the march probably will start today at one of the alternative locations and proceed to the Iranian Embassy.

Supporters of the protest said they hoped it would include both U.S. and Iranian students concerned about the Iranian situation, and that they expect about 100 persons to participate.

The U.S. Court of Appeals panel scheduled the 11 a.m. hearing yesterday after the Justice Department filed an emergency appeal of Robinson's ruling over the weekend. Assistant U.S. Attorney Royce C. Lambreth told the court yesterday that the government should be allowed to take the rare step of banning a specific protest because "there is a clear and present danger to the almost 60 Americans held hostage. In the history of our nation, this event is unparalleled."

He cited earlier testimony by Deputy Secretary of State Warren M. Christopher that the Iranians might wrongfully preceive a "governmental aura" if the demonstration occurred near the White House.

Lambreth said the administration does not want to ban all demonstrations, but it is merely trying to regulate the time, place and manner in which they can proceed -- and at the same time protect the hostages.

ACLU attorney Mark Lynch argued, however, that the government had not shown there was enough threat of danger to warrant limiting First Amendment rights.

After the morning hearing, the court recessed for three hours to see if the groups could reach a compromise on the planned event.

The two sides exchanged letters outlining their positions, then asked the court for a further public hearing to report on a demonstration that occurred yesterday morning in Lafayette Square.

Lambreth told the appealate panel -- Judges J. Skelly Wright, Harold Leventhal and Roger Robb -- that the march by the Revolutionary Communist Party, a Maoist group, "turned into" a demonstration about the Iranian situation.

He said the group had told government officials the march would protest the prosecution of the group's leader on criminal charges here, but that as it proceeded, the group unfurled a banner that said, "The shah must face the wrath of the Iranian people."

The demonstration ended in Lafayette Square with about 600 protesters chanting anti-U.S. slogans, Lambreth noted.

Although the demonstration proceeded without any violence from counterprotesters, Lambreth said the government had not changed its position that such incidents might provoke violence from counterprotesters and be the catalyst for actions against U.S. hostages by their Iranian captors.

The court said in its ruling, read by Chief Judge Wright, that " the fact that other nearby sites are available" for the protest was a "material consideration in our conclusion."

ACLU attorney David Landau said his group considered the ruling a partial victory because the government was forced to back down from its earlier moves to ban all Iran-related protests, and instead to bar them only from Lafayette Square. However, he said, the ACLU plans to continue its challenge to that ban on the merits of the case once the hostage situation ends.