Iran today published a purported confidential message from President Carter to Ayatollah Ruhollah Khomeini that ostensibly was designed to ease U.S.- Iranian tensions, but appeared to have backfired in mutual recriminations and denials.

In Washington, White House press secretary Jody Powell said categorically that Carter had not sent such a message. He added: "Neither the president nor anybody else in the administration sent such a letter to Khomeini or anybody else over there."

Powell's public denial was backed up privately by several administration officials dealing with the Iranian crisis. They insisted that, if such a message does exist, the administration knows nothing about its origin or what motive the Iranians might have had in making it public.

Released without commentary by Khomeini's office on the national news wire, radio and television, the message caught Iranian officials by surprise.

Neither public officials nor private citizens had been prepared for such conciliatory American language -- or its implications of previous consultations. The comedy of errors that ensued all but obscured the content of the alleged message.

The purported message said Carter understood the "reasonable reaction of the youth of Iran" in seizing the U.S. Embassy last Nov. 4, but warned that their continued custody of the estimated 50 American hostages created as many problems for the Iranian government as it did for the United States.

The message suggested a joint U.S. Iranian commission should be established to settle all outstanding bilateral problems but only once the hostages had been transferred from the control of the embassy militants to the Iranian government.

The Iranian astonishment was compounded when White House press secretary Jody Powell denied such a message had ever been sent.

However, reliable intermediaries trusted by both the White House and the Iranian government had said days before the purported message was made public that it existed, and alluded to its content in general terms.

The alleged message was said to have been made orally originally, and to have passed through several hands before reaching Tehran, where it was translated and written down in Farsi for presentation yesterday to Khomeini.

Indicative of official Iranian reaction, before Powell's denial, was Foreign Minister Sadegh Ghotbzadeh's effort to justify the publication by lauding Carter's "honest gesture which should be considered very favorably by all parties concerned."

But after the White House statement, Ghotbzadeh said "I have seen the message and had it translated into Farsi."

He warned that the White House denial "will destroy any possibility of faith Iranians still have in anything the American government says or does."

The purported message went a long way toward meeting Iranian demands for American acceptance of past U.S. interference furing the reign of ousted shah Mohammad Reza Pahlavi.

Playing on both Carter's and Khomeni's fears of Soviet designs against Iran, the message insisted that the administration had inherited its broad relationship with the shah, but now was anxious to "accept new facts" and have "new relations" with the revolutionary government.

Throughout the message were scattered references to American consultations with President Abol Hassan Bani-Sadr and the congressional hearings on past U.S. relationships with the shah's Iran, which the administration agreed to last week.

The Carter administration has made amends for its errors in Chile, has worked out new relations with revolutionary Nicaragua and wants to go beyond "past mistakes" with Iran, the purported message said.

"The great advantage of American democracy is that it can recognize its past mistakes and condemn them," the official Pars news agency version of the message said.

Stressing the Soviet threat perceived by both sides, the message said the administration shared Iran's insistence on respect for the sovereignty of nations and the right of peoples to self-determination.

It specifically mentioned U.S. defense on such principles in Nicaragua, Afghanistan and the "probable danger to the sovereignty of Yugoslavia" once ailing President Tito dies.

Returning to the Soviet menace, the Carter message ended with the president quoted as saying "time and the real enemies of our political systems are working against us."

On the sensitive issue of the shah's sudden departure from Panama last Sunday, the message said the administration discouraged his return to the United States for medical treatment, did not know of his negotiations to go to Egypt and that his departure was a "private decision."

"We handed over all the information about the shah's health" to Bani-Sadr, the message said, apparently in an effort to convince Iran of the seriousness of his illness -- the subject of much doubt here.

Looking at the message from a perspective that assumes it exists, analysts were at a loss to explain why it was released. But in the light of previous misunderstandings in the nearly five-month-old crisis, a combination of clumsiness, sabotage and anti-American gloating could be ruled out.

Some observers suggested that the White House may have insisted on this indirect form of conveying this message for fear that Khomeini would indeed publish any formal letter without the administration being able to deny its contents.

Khomeini and the ruling Revolutionary Council have made promises in the past which have not been kept. Earlier this month, the ayatollah's entourage sabotaged efforts to keep a United Nations commission here by breaking a self-imposed deadline and publishing new terms for granting the investigators permission to visit the hostages.

Pessimists suggested that the Carter administration may have laid itself open to this new embarrassment Wednesday when Secretary of State Cyrus Vance agreed to publish a white paper on U.S. relations with Iran under the deposed shah.

The pessimists reasoned that such an unreciprocated gesture only encouraged Khomeini to follow up with his new surprise, depicting the United States as willing to make amends for past wrongdoing.

Optimists argued that the message could help unfreeze that steadily deteriorating relations between the United States and Iran by provoking a kind of psychological breakthrough.

Among arguments marshalled to defend this view were:

For the first time, Khomeini and Carter were seen in direct consultation despite the ayatollah's haughty insistence in the past that no negotiations were possible with the United States.

The message demonstrates American willingness to turn a new page in relations with Iran, something that although obvious to the American public had been obscured all too often in Iran.

Khomeini can no longer deny the web of behind-the scenes consultations involving the United States and Bani-Sadr.

Willy-nilly, the Iranian public now is aware of what has been going on in an effort to solve the crisis.

The same applies to Khomeini himself, who throughout the crisis, according to an increasing body of evidence, has either purposely ignored or been kept willfully ignorant of most detailed diplomatic efforts to find a settlement.

In Washington, staff writer John M. Goshko reported:

Confusion about the purported message, amid denials that it came from Carter, was compounded by the fact that some of the ideas outlined in the message are known to have been under consideration by the administration last month as possible ways of breaking the impasse over the hostages.

In a background session with reporters on March 8, Carter, while asserting that under no circumstances would be apologize to Iran, said he was willing to make an expression of concern about how past developments have affected the current state of U.S.-Iranian relations. Much of the language in the alleged message to Khomeini appears to follow that line.

Similarly, at the time negotiations were underway on creating the U.N. commission, the United States is understood to have signaled its willingness to seek a means of "normalizing relations" with Iran after the hostages were freed. That idea, also, is echoed in the purported message's reference to U.S. willingness to accept creation of "a joint commission as the means of investigating the questions of both sides . . ."

Still, while the main thrust of the purported message is not inconsistent with ideas the United States has communicated to Iran in the past, U..s officials insisted yesterday that the message is not genuine. They specificallly cited some passages of the text as things that Carter would never say.

In particular, they pointed to the language saying that "the occupation of our embassy in Tehran could have been considered a reasonable reaction by the youth of Iran . . ."

That, the officials noted, runs directly counter to the U.S. stance, maintained both publicly and privately, that the embassy seizure was a wholly unjustified act in violation of international law and that the militants are not "youths" or "students" but thugs and fanatics working for their own ends.