WASHINGTON — Few American presidents have held a deeper belief in the power of the written word than President Obama. And in few ways has that belief been more tested than in his frustrating private correspondence with the leaders of Iran, a country with which the United States has had no diplomatic ties for 34 years.

This week, Mr. Obama indicated that he might finally have found a pen pal in Tehran.

At the core of Iran’s recent diplomatic charm offensive — a process that has included the release of 11 prominent political prisoners and a series of conciliatory statements by top Iranian officials — is an exchange of letters, confirmed by both sides, between Mr. Obama and President Hassan Rouhani.

The election of Mr. Rouhani, a moderate, in June kindled hopes that diplomacy might end the chronic impasse with Iran over its nuclear ambitions. But the letters, and the cautious hope they have generated, suggest there is a genuine opportunity for change.

It is not the first time since entering the White House that Mr. Obama has put pen to paper to try to sway Iran’s leadership. Until now, he has had little to show for it: even under the pain of punishing economic sanctions, the Iranian government has shown little interest in negotiating a deal with Washington on its nuclear program.