Five months ago Iran's foreign minister sent an unusual letter to the country's supreme leader, Ayatollah Ali Khamenei. It was time, Ali Akbar Salehi wrote according to two sources who read the letter, to reach out to Tehran's arch foe by entering into "broad discussions with the United States."

The supreme leader, though cautious about the prospect, sent a reply to Salehi and the rest of the Cabinet: he was not optimistic but would not oppose them if they pursued the initiative.

Salehi's move was bold on many counts, not least the risk it posed to him in bypassing outgoing Iranian president Mahmoud Ahmadinejad. The outgoing president has fallen out of favor with the supreme leader in recent years and openly opposed Salehi's proposal, the sources said.

"Salehi endangered his career - and even his security," said a source who knows Salehi and saw the letter. "But he said this letter will be registered in history."

The three-page handwritten letter, reported here for the first time, is the latest Iranian proposal for dialogue between Tehran and the United States, which are at odds over Iran's nuclear program. Iran says it is for peaceful domestic purposes, but Western countries and many in the Middle East believe it is aimed at producing bombs.

So far, the letter has led nowhere. But a Reuters examination of the relationship between Washington and Tehran reveals it is even more complex than commonly understood, though still distant and untrusting. Based on interviews with diplomats, current and former government officials, intelligence sources and well-connected academics, it shows how infighting in Iran and suspicions in the United States have so far blocked attempts to thaw relations.

It is not clear whether Salehi's proposal signifies a change of tack by Khamenei's camp or will lead anywhere, though a former senior Iranian official said Khamenei's green light for direct talks with the Americans will remain valid even after the June 14 presidential election.

Iran's U.N. mission did not respond to a request for comment.

Western powers hope Ahmadinejad's successor will be someone who is on good terms with the supreme leader, avoids anti-Israeli rhetoric and supports serious negotiations on Iran's nuclear program. But the choice for Iranian voters is limited. Iran's reformists, who might be more inclined to compromise over the nuclear program, have been barred or sidelined in the election. The six carefully vetted presidential candidates are dominated by hardliners close to Khamenei.

Karim Sadjadpour of the Carnegie Endowment for International Peace, a leading Iranian-American expert on Khamenei, remains pessimistic that any deal can be struck with the United States while the 73-year-old Khamenei is alive.

"Those who want a deal can't deliver, and those who can deliver don't want a deal," Sadjadpour said.

After more than three decades without diplomatic relations, suspicion runs deep on both sides. Yet behind the scenes both Iran and the United States have shown more interest in some kind of dialogue than commonly thought.

OBAMA LETTERS

Ten years ago last month Iran sent the administration of then-President George W. Bush a secret proposal for wide-ranging bilateral talks to resolve disagreements on many issues, including its nuclear program. Some in the U.S. State Department wanted to move on the proposal; but the Bush administration dismissed the idea of dialogue with a country it had branded part of an "axis of evil" with North Korea and Saddam Hussein's Iraq.

That rejection undermined reformists, former Iranian nuclear negotiator Hossein Mousavian wrote in his 2012 memoirs. There were no subsequent offers of broad negotiations with Washington that could claim to have Khamenei's support, according to Western diplomats and officials.

When President Barack Obama took office in 2009 he reversed the U.S. line and offered Khamenei direct engagement - provided Iran was serious about ending concerns over its nuclear program. Obama twice wrote directly to Khamenei, in 2009 and again in 2012.

The letters have never been published, though some details were leaked to reporters. Unknown until now is that Obama proposed a list of American interlocutors who could negotiate with the Iranians. One possible go-between, according to one source, was William Burns, now deputy secretary of state and previously the chief U.S. negotiator in six-power negotiations on the Iranian nuclear crisis.

Khamenei, who has final say on all domestic and foreign policy matters, never reciprocated with his own list of Iranian negotiators, the sources told Reuters.

"One of the difficulties in getting negotiations with Iran going is who you talk to," a former Obama administration said on condition of anonymity. "You need to talk with the supreme leader or someone who's close to him. No one else matters. And the supreme leader has been unwilling to talk with us."

Obama administration officials insist they are serious about engagement with Iran, but also about preventing Iran from acquiring nuclear weapons. "The onus remains with Iran if it wants to pursue a path to end its isolation," said Caitlin Hayden, a National Security Council spokeswoman. "We hope that Iran's leaders will choose to make concrete progress towards addressing international concerns and finding a diplomatic solution. We certainly remain ready to so, but the window for diplomacy is not open indefinitely and all options are on the table."

Dennis Ross, a veteran U.S. diplomat who advised Hillary Clinton in the State Department and then spent two years on Obama's national security staff is more blunt: "The administration was up for bilateral. It's not that it didn't happen because the U.S. was reluctant to do it. It didn't happen because the Iranians weren't prepared for it."

Israel, which considers Iran's nuclear program one of its top security threats, was initially suspicious of Obama's willingness to engage with Tehran, U.S. and Israeli officials have said. But over time they realized that Obama's commitment to engage helped win him the international backing to implement painful sanctions against Tehran, Western officials told Reuters.

While more pragmatic elements in Iran's opaque collection of clerical councils, ministries and advisory groups have indicated an interest in dialogue with America and a diplomatic solution to the nuclear standoff, Khamenei's office has resisted direct negotiations, say U.S. and other Western diplomats. It has pressed ahead with nuclear enrichment in defiance of U.N., U.S. and European Union sanctions.

The only American to have had a one-on-one, face-to-face meeting with the supreme leader is the former Episcopal Bishop of Washington, John Bryson Chane.(When U.N. chief Ban Ki-moon met Khamenei in 2012 in Teheran, Jeffrey Feltman, a former U.S. State Department official, was also present but in his capacity as U.N. Under-Secretary-General, not as a U.S. citizen).

Chane told Reuters he met Khamenei on the sidelines of a conference on religion and politics in Tehran in 2008. Khamenei talked to Chane about "Iran's troubled relationship with the West," including the U.S. and British role in overthrowing the democratically elected government of Prime Minister Mohammad Mossadegh in 1953 and Washington's subsequent support for the autocratic Shah of Iran.

Chane remains in contact with Khamenei and has occasionally acted as a go-between. In 2011 he played a role in helping to secure the release of two American hikers. He keeps his distance from the U.S. government but told Reuters he had agreed to relay messages between the State Department and Khamenei's office in the past. He did not provide any details.

AHMADINEJAD OVERTURES

Though Khamenei mostly stayed silent, Ahmadinejad, who became Iran's president in 2005, did not. The politician widely vilified in the West for doubting the Holocaust and questioning Israel's right to exist, sent a letter to Obama in 2008 congratulating him on his election victory.

Then in 2009 Ahmadinejad made an offer, delivered by U.N. nuclear watchdog chief Mohamed ElBaradei, of direct talks. Obama showed little interest, partly because of Ahmadinejad's public comments on the Holocaust and Israel, but mainly because he was seen as unable to sway the supreme leader, Western and former Iranian officials say.

Nevertheless, there were informal contacts.

"Despite radical rhetoric, Ahmadinejad did more than all his predecessors to (try to) advance rapprochement with Washington," a source familiar with Iran-U.S. contacts told Reuters. Other Western diplomats confirmed that view, which runs counter to the standard portrayal of the Iranian president as unwilling to compromise on the nuclear program.

On the sidelines of a 2009 meeting in Geneva, Iran's chief nuclear negotiator Saeed Jalili held bilateral talks with then-U.S. Undersecretary of State William Burns, the highest level bilateral U.S.-Iranian meeting in three decades.

Since Ahmadinejad took office there have been "tens of covert meetings between Iranian officials and former U.S. officials in ... the Hague, Geneva, Vienna, Sweden, Tehran, Munich and New York," the source said. Most of those meetings have taken place since Obama arrived in the White House in 2009, sources familiar with them said.

Reuters met several individuals who participated in at least some of those discussions. One, former U.S. Ambassador to the United Nations Thomas Pickering, was involved in indirect talks with Iranian counterparts as part of so-called "Track II" informal diplomacy.

Various proposals for ending the nuclear standoff were floated to Iran in different Track II meetings, which Pickering said in his case were set up by the United Nations Foundation of America. Proposals ranged from scrapping enrichment of uranium to limited enrichment work and 24/7 monitoring by the International Atomic Energy Agency (IAEA).

The discussions included meetings with Iran's U.N. Ambassador in New York, Mohammad Khazaee, Tehran's sole official diplomatic representative on U.S. soil, and other Iranians living in the United States who have "different degrees of contacts back there." None of the initiatives went far.

"I don't think we penetrated the fundamental mistrust on their side that somehow regime change was the only acceptable end result for the U.S. and that on our side a nuclear weapon was the only acceptable end result for Iran," said Pickering.

"The two (views) may be true but they represent extremes, and the real interest of negotiations is can it find an answer between those extremes."

A FAILED DEAL

The most serious overture from Ahmadinejad's camp came in 2009, shortly after Ahmadinejad's divisive re-election, which sparked nationwide protests accusing him of rigging the vote.

Iran's mission to the IAEA in Vienna approached the agency's head at the time, Mohamed ElBaradei, to ask how they could get new fuel for the ageing Tehran Research Reactor, a small nuclear facility bought from the United States in the 1970s that produces medical isotopes.

ElBaradei approached the Americans, who saw an opportunity for a deal. They suggested Iran could ship 1,200 kg of their low-enriched uranium - 80 percent of all they had - to Russia for enrichment to 19.5 percent uranium-235 purity, which would be suitable for the research reactor. The uranium would then go to France for processing into special fuel assemblies.

If Iran had gone through with the deal, it would have shipped the bulk of its low-enriched uranium out of the country for a year, which U.S. officials said at the time would have dramatically reduced tensions in the Middle East amid concerns that Israel was preparing to attack Iran's nuclear facilities.

Ahmadinejad jumped on the proposed deal, seeing it as an opportunity to make a breakthrough in the so-called P5+1 talks on Iran's nuclear crisis involving the five permanent members of the U.N. Security Council - Britain, China, France Russia and the United States - and Germany.

"It was Ahmadinejad's baby," said a senior Western diplomat involved in the negotiations. "He saw it as a chance to promote himself ... as the man who helped restore Iranian relations with the U.S."

The deal fell apart when Ali Larijani, speaker of Iran's parliament, attacked it as selling out to the West. Larijani and other Iranian officials were also suspicious that Ahmadinejad was trying to usurp some of the supreme leader's authority.

"Ahmadinejad has no respect for the leader, he just wanted to remain in power," a source close to Khamenei told Reuters. "All of his opponents inside the system were well aware of it.

"That is why Khamenei blocked his approaches several times to show Ahmadinejad and the world that he (Khamenei) was the real boss."

AFTER THE ELECTION

After two consecutive terms, Ahmadinejad must now step down.

Might the transition, and the bite of sanctions, prompt a shift from Khamenei, as hinted at by the foreign minister's letter? The hurdles remain formidable, though U.S. and other Western officials say U.S. Secretary of State John Kerry is determined to pursue a new diplomatic push with Iran, including direct talks.

Sources familiar with Iranian thinking said it would be extremely difficult for Khamenei to agree any kind of deal with the Americans, because doing so could undermine his credibility among his conservative power base.

Others say that, though difficult, even Khamenei could drink "the cup of poison," as his predecessor Ayatollah Ruhollah Khomeini described it when he reluctantly agreed to a U.N.-mediated truce that ended the 1980-88 Iran-Iraq war.

Iran's economy, which analysts say has been weakened by sanctions and mismanagement, might be one reason for Khamenei to consider talks. U.S. and EU restrictions on Iran's oil exports and international financing have contributed to a collapse in Iran's currency and soaring inflation.

"On the one hand he (Khamenei) dislikes the idea of opening up to the Great Satan but at the same time he knows that it is (the) only way to resolve the country's economic problems," said a former high-ranking Iranian official who was imprisoned for two years after the 2009 election on charges of "acting against national security."

"The economy is Khamenei's red line," he said.

Ross, the veteran U.S. diplomat, said Khamenei's unwillingness to speak with the United States is partly because he underestimates Obama's readiness to use force to prevent Iran from acquiring a nuclear weapon. A former senior Iranian official confirmed that Khamenei thinks Obama is not yet willing to attack Iran.

"Right now, he (Khamenei) does not believe that we have reached that point," said one of Iran's former top nuclear negotiators, who was dismissed by Ahmadinejad.

"Khamenei and his close allies strongly believe that America will not attack Iran, but are worried about Israel," the negotiator said. "They will wait until the last possible minute."

Bishop Chane believes that for the time being Track II diplomacy is the best hope for encouraging engagement.

"It is possible to have a dialogue with Iran," said Chane, who will join others in Doha in June for further Track II discussion that are expected to include senior Iranian clerics.

"But we in the West have to show some respect for Iran, for its culture and its religious heritage. There has to (be) a way to trust and verify."