Iranian militants holding the U.S. Embassy here said yesterday that 13 American hostages would be released in two groups shortly. But they and ruling Ayatollah Ruhollah Khomeini warned that many of the remaining hostages might be put on trial for espionage.

The three released hostages, embassy secretary Kathy Gross and black Marine Sgts. Ladel Maples and William Quarles, were escorted out of the embassy in an American auto and taken to the airport, where they were placed aboard a flight to Copenhagen.

The air departure came less than an hour after the official state radio announced that 10 others, six blacks and four women, had been released to the care of a doctor and a Red Cross team.

Reporters at the embassy and the airport, however, said only the three had been seen leaving the embassy, followed by two cars carrying armed Revolutionary Guards. The militants had said yesterday that 13 of the more than 70 hostages would be released in two groups today.

Observers suggested that Khomeini may have intervened with the hardline students. They had been defying the divided Revolutionary Council and Khomeini by failing promptly to obey the ayatollah's broadcast order Saturday to free all the blacks and women among the more than 70 hostages, who began their third week of capitivity yesterday.

Even if 13 hostages were released, two women and perhaps two black men apparently would remain unaccounted for and possibly fall into the "spy" category Khomeini specifically excluded from release.

Khomeini, in televised interviews with the three major U.S. networks, raised the possibility of espionage trials for an unspecified number of hostages if the United States fails to extradiet the deposed Shah Mohammad Reza Pahlavi to Iran for trial. The shah is undergoing treatment for cancer at a New York hospital.

Speaking to the television reporters in Qom, the holy city 80 miles south of the capital, Khomeini warned that he could not guarantee that any hostage convicted of espionage would have his or her life spared.

Asked by NBC if Iranian revolutionary courts might return a death sentence, the 79-year-old Moslem leader declined to give a direct answer, saying, "That cannot be known."

By engaging in espionage, Khomeini contended, diplomatic immunity and make themselves liable to prosecution.

In his interview with CBS, Khomeini called on the people of Egypt to overthrow President Anwar Sadat "as we overthrew the shah." Sadat has called Khomeini's actions a "disgrace to Islam."

Yesterday the militants presented Gross, 22, of Cambridge Springs, Pa., Amples, 23, of Earle, Ark., and Quarles, 23, of Washington, to reporters for questioning and announced that they would be the first hostages freed.

Answering questions in front of Iranian and foreign press invited to the embassy, the three gave differing accounts of their treatment. They said they did not know why more hostages -- especially the six other women and estimated six or more other blacks whose liberation had been promised yesterday -- have not been ordered released.

All three seemed remarkably chipper despite their ordeal, which included being tied in a chair 16 hours a day, being cut off from news from the outside world and not being allowed to talk to other hostages, even those held in the same room.

Khomeini's warning about possible espionage trials made it clear that he was not backing down in the face of American pressures and critical world public opinion.

Similar motives were ascribed by analysts to explain:

The long delay in actually arranging the departure from Iran of the first hostages.

The students' decision to hold an evening news conference with the three despite earlier assurances that ruling Revolutionary Council members favored maximum discretion to entice the United States into making a gesture to help solve the crisis.

The biggest loser in all this maneuvering appeared to be Abol Hassan Bani-Sadr, the acting foreign minister and the man officials in Washington had begun to consider the one authoritative Iranian official with whom they could work.

Not only was he unable to make good on promises to liberate all the women and black hostages rapidly, but the students rejected his proposal for an international commission to investigatge the shah's alleged crimes.

Furthermore, Aytollah Mohammed Beheshti, the Revolutionary Council's secretary general, publicly has contradicted Bani-Sadr, who also serves as finance and economy minister. Beheshti said the ruling body had not yet banned dollars for oil payments, thus overruling Bani-Sara.

Saturday night, Hassan Habibi, the Revolutionary Council's spokesman, said Bani-Sadr had received the council's formal confirmation of this.