The United States for the first time yesterday raised the possibility of taking military action against Iran if the remaining American hostages in Tehran are not freed.

In a dramatic escalation of the controntation with Iranian authorities, the White House issued a statement late yesterday that, while carefully avoiding any direct reference to military action, implicitly suggested the possibility of a military move on grounds of self-defense as authorized in the United Nations charter.

"The United States is seeking a peaceful solution to this problem through the U.N. and every other available channel," the statement said. "This is far preferable to the other remedies available to the United States. Such remedies are explicitly recognized in the charter of the United Nations. The government of Iran must recognize the gravity of the situation it has created."

Although the statement did not cite specific "remedies" available to the United States, it was made clear to reporters that the key section of the U.N. charter is Article 51, which states:

"Nothing in the present charter shall impair the inherent right of individual self-defense if an armed attack occurs against a member of the United Nations, until the Security Council has taken measures to maintain internatioal peace and security."

The U.S. interpretation of the article, it was also made clear, is that the continued holding of the hostages and their threatened trial as spies amounts to an attack on the United States.

The dramatic development came after a more than hour-long meeting of President Carter and his top foreign policy advisors at the White House. Looking exceedingly grim, Carter reached the White House from Camp David at 4 p.m. He left for the return trip by helicopter to the presidential retreat at 5:45 p.m.

It was not clear last night what triggered the decision to escalate the confrontation. But it came after White House officials closely studied news accounts of a speech yesterday by Ayatollah Ruhollah Khomeini in which Iran's leader threatened to put the 49 American hostages who remain in the embassy on trial as spies.

The White House statement said such trials "would be a flagrant violation of international law and basic religious principles, and the government of Iran would bear full responsibility for any ensuing consequences."

It was clear that the United Sttaes will not be satisfied if Iranian authorities merely drop the threat of spy trials, but is demanding that the hostages be freed.

The White House statement climaxed a day in which there was a flurry of reports that former United Nations ambassador Andrew Young might be traveling to Iran as an unofficial mediator. But last night, the possible Young mission appeared sidetracked by opposition from the administration.

White House and Defense Department officials refused comment when asked about possible movement of U.S. naval or military forces toward Iran. But reliable sources said the aircraft carrier Kitty Hawk, a cruiser and three destroyers had been ordered to proceed from the Philippines to the Indian Ocean. Another carrier, the Midway, already is in the Arabian Sea near the Persian Gulf.

Until yesterday, the administration had consistently declared that military action was not being considered. Instead, it had relied on a number of diplomatic efforts mounted through third countries.But these have been rebuffed as Iranian authorities have insisted that the hostages will be freed only if the United States returns to Iran the deposed Shah Mohammad Reza Pahlavi, who is undergoing treatment for cancer in New York.

Diplomatic sources at the U.N. said Third World representatives there were trying to work out a three-part package consisting of a guaranteed release of the hostages, a public debate in the Security Council that would allow Iran to air its grievances against the United States, and the creation of an international commission that would weigh the question of the shah's guilt without putting the United States under any legal obligation to extradite him.

These points probably would be acceptable to the United States, if it were clearly understood that release of the hostages had to come first and that the international commission could not do anything in conflict with U.S. law. But, while a diplomatic solution obviously is favored by Washington, yesterday's hint of military action apparently reflected a decision that U.S. willingness to negotiate, must be backed up with a show of muscle.

In New York, the U.N. Security Council president again pleaded that the remaining hostages "be released without delay." However, the Security Council did not go on record against spy trials for the 49 remaining American hostages, because 13 of the 14 council members objected to such a public statement.

Clearly, the threat of spy trials was a major factor in the president's decision to escalate the confrontation. But administration sources said last night that the decision was prompted not by a single factor but by the accumulation of events during the takeover of the embassy, which began Nov. 4. a

A senior official said last night that the decision to issue the statement was made during the day in telephone conversations between Carter and his foreign policy advisers. The president returned to the White House to review and approve the statement's language.

The key factor, the official said, was Khomeini's speech, with its threat of the spy trials and call for a massive anti-American demonstration throughout Iran today.

"It was felt that now it is appropriate for us to underscore, in public fashion, the consequences in the event that any harm comes to our people," he said.

The United States apparently decided to voice its implicit threat of military action without consulting allies. However, Iranian authorities apparently had been forewarned, at least indirectly, to expect some such public move.

Following the White House meeting Secretary of State Cyrus R. Vance went to Capitol Hill to meet with Senate Majority Leader Robert C. Byrd (D-W.Va.) and Foreign Relations Committee Chairman Frank Church (D-Idaho).

Earlier yesterday, a flurry of confusion arose from reports that Young was planning to go to Tehran in an unofficial effort to free the hostages.

His proposal encountered strong opposition from the administration, and sources close to Young said last night he was returning home to Atlanta and dropping -- at least for the time being -- the idea of a trip to Iran.

Since the beginning of the crisis, Young has been mentioned repeatedly as a posible negotiator because of the high standing he earned in Third World circles before his resignation fron the U.N. ambassadorship last summer.

According to the sources, Young has kept in touch with the State Department throughout the crisis. They said Young offered to make the trip after Prof. James Bill, an Iranian-affairs expert at the university of Texas, advised him of hints from Iran that he would be received "at a high level" if he went.

However, administration sources said Young was told that the White House was opposed to a trip by him or any other unofficial mediator unless there was a prior commitment from Khomeini that the hostages would be freed.

Although Young was in Washington yesterday, the sources said he had no discussions at the State Department about Iran. But he was understood to have made further soundings about the desirability of an Iran trip and, after finding the administration's opposition unchanged, decided not to pursue the matter at this time.

Former secretary of state Henry A. Kissinger, addressing a meeting of Republican governors in Austin, Tex., yesterday, said public reaction to the embassy takeover shows that the people "are sick and tired of getting pushed around, and they are sick and tired of seeing America forever on the defensive."

Kissinger, who has been singled out for special attack in Iran because of his close relations with the shah and his advocacy of allowing the shah into the United States, said, "Every American president of both parties [from Truman on] benefited from the support of the shah."

Kissinger called the threat of spy trials "an outrage," and said: "I'll support the administration in whatever they think is appropriate to do . . .All Americans should now rally behind the administration."