Iran's government-controlled television showed two American hostages early Thursday who said the U.S. Embassy here and some of its personnel were involved in "espionage."

The two hostages described secret communications monitoring activities and spoke of aerial photography by a specially equipped U.S. plane. The alleged flights would have taken place during the shah's reign.

The name of the first hostage was not clearly identifiable in the mid-night broadcast. The second hostage shown reportedly identified himself as "Staff Sgt. Subic." Army Staff Sgt. Joseph Subic Jr., 23, of Bowling Green, Ohio, was assigned to the embassy defense attache's staff last June and has been identified as one of the hostages.

It was not immediately known when the pretaped television footage was filmed, but the timing of the broadcast, following the severance of diplomatic and remaining trade relations with Iran by the United States, raised the prospect that the militant Moslem captors and their supporters now would press for long-demanded hostage trials.

Efforts to obtain a tape of the broadcast from Iranian television officials and positively identify the Americans were unsuccessful.

The broadcast followed a warning Wednesday by the militants that they would "destroy" all their hostages if the United States followed up its political and economic sanctions with "the slightest military intervention."

The broadcast and that statement -- the harshest threat against the hostages by the captors since a U.S. naval task force steamed into the Persian Gulf area late last year -- seemed to undermine a pledge by Foreign Minister Sadegh Ghotbzadeh to allow more visits to the hostages by outsiders, including their families.

The militant students later ruled out visits by members of their captives' families and said they would only admit persons they had invited themselves.

Amid the threat to the hostages and the broadcast airing the alleged spy activities, the situation on the Iranian-Iraqi border continued to deteriorate, with new clashes reported. Meanwhile, Ghotbzdeh warned that Iran would help overthrow the Baghdad government "if Iraqi intervention continues."

In the midnight hostage broadcast, the first American shown was seated behind a desk in a room identified as the defense attache's office in the embassy chancery. Response to questions asked by one of the militants, he denounced the deposed shah, Mohammad Reza Pahlavi, and criticized President Carter for allegedly putting the shah's welfare above that of the hostages.

According to a Persian-language narration that often made the hostage's statements in English inaudible, the American said, "I've seen people tortured by SAVAK, and with holes in their heads. I've seen pictures of some members of Congress in the nude with the shah's sister and in shameful activities."

The narration quoted him as calling for the shah to be put on trial as an international criminal.

Other statements of the hostages that were audible corresponded fairly accurately to the translation in the Persian-language narration.

The blond hostages, who appeared to be about 30 years old and was wearing a V-neck sweater, said, according to the narration, that U.S. personnel in Iran operated an aircraft indentified as a C12 with "cameras fixed under the seats of the pilot and copilot for taking pictures for espionage purposes."

The second American shown appeared to be in his early twenties and was wearing camouflage fatigues, a red T-shirt and round, wire-rimmed glasses. He had short brown hair and wore a sparse mustache.

The first hostage was on too briefly to evaluate his well-being, but the second hostage, who appeared much longer, seemed lucid and in good condition.

"I'm standing in the warehouse of the embassy," he said to the camera. He took up a section of carpet and, in audible English, said, "This is a computer carpet."

Under it, he removed sections of a metal grid floor that concealed six bundles of wire underneath it.

"These computers used to work during the time of the shah," the narration quoted him as saying. In English he was heard to say, "We would monitor radio wavelengths to find out what was going on." There was also an unclear reference to monitoring "computer traffic."

Intelligence sources have said in the past that monitoring of communications was a common embassy function also performed by other countries. The sources said that Soviet embassies in Tehran and Washington were known to carry out similar monitoring. Before Iran's February 1979 revolution, one intelligence source here said that the Soviets maintained about 40 full-time intelligence officers in Tehran.

According to the narration, the second American explained that after the revolution, the embassy was wary of using its monitoring facilities because they used up so much electricity that it was feared that the Iranian government would become suspicious.

To resolve the problem, the hostage was quoted as saying the embassy ordered extra electric generators that were to have been delivered two weeks after the embassy takeover Nov. 4.

"If this had been revealed, it would have been a major blow to the U.S. because very important espionage information was being obtained through these means," the Persian narration quoted the hostage as saying.

After removing ceiling panels that revealed more wires, the hostage pointed to a junction box and said in audible English, "This went to the National Security Agency." Pointing to another, he was heard to say, "CIA."

The hostage said it had been surprising that the generators cleared Iranian customs as quickly as they did.

"It brings in the question of who's in cushoms, whether it's a CIA man or not," the hostage said.

Referring to the ostensible use of the buildings that housed the monitoring equipment as a warehouse, the young American said, "They built this building here and put these supplies on top of it to conceal its real identity."

He added that embassy personnel sold liquor from the embassy stock, apparently before the revolution.

"We had enough to last for seven years for all the people in the embassy -- that's about 120 people," the hostage said. "There was $2 million dollars' worth. I'm talking about whisky, the hard stuff -- not the beer or wine."

At the beginning of the broadcast, an Iranian speaker had introduced the program by saying, "These are two spies and they are going to reveal some shocking things."

Subic was one of four hostages who read stagements on Iranian television during the Christmas holidays. He has written numerous letters to U.S. newspapers urging the shah's return to Iran to stand trial.

In response to the announcement of U.S. sanctions against Iran, the militants issued a statement Wednesday saying, "We warn the criminal U.S. government explicity that if that government carries out the slightest military intervention against Iran we will destroy all the spy hostages together . . ."

At a news conference, however, Foreign Minister Ghotbzdeh adopted a much more moderate tone, saying that there would be no retaliation for the sanctions because they "don't mean anything."

Meanwhile, Iran's tensions with neighboring Iraq escalated with Iranian news broadcasts reporting that an Iranian jet fighter and three military helicopters fought an air battle with Iraqi helicopters Wednesday above the Iranian border town of Baveissi. No planes were shot down, but 15 Iranian Revolutionary Guards were wounded in artillery barrages and rocket attacks, the broadcasts said.

There was no independent confirmation of the clashes and Iraq restricted its comment to accusing the revolutionary government in Tehran of trying to subvert the Baghdad government.