I sat in the gallery above the floor of the House of Representatives on Tuesday night surrounded by a broad cross-section of American society that had gathered to witness the national institution known as the State of the Union, or the Address to a Joint Session of Congress as it is known during a new president’s first year in office.

From my seat among the guests, I could glimpse at least eight women wearing the Islamic hijab, including Aneelah Afzali, a lawyer and the director of the American Muslim Empowerment Network, who wore a scarf with the American flag on it. I could see Mona Hanna-Attisha, an Iraqi American who uncovered the lead in water crisis in Flint, Mich., and José Andrés, the Spanish-born chef who is being sued by President Trump after pulling out of plans to open a restaurant at the Trump International Hotel in Washington. Around me, too, were plenty of Republican supporters of the new administration; Layton Ricks, the president of Livingston Parish in Louisiana, was seated next to me.

All had been invited for a particular reason by a politician in the room. And as the main chamber of Congress began to fill, marking the start of the night’s pageantry, I felt very aware of the strange circumstances that had brought me to this moment.

At the last State of the Union, President Barack Obama’s eighth and final one, some people in this chamber had worn pins with “#freejason” written on them. My fate had become a public issue in the contentious political struggle over the Obama administration’s nuclear deal with Iran and its controversial policy of engaging longtime adversaries. I had also become a symbol of the dangers faced by journalists around the world and the ongoing international struggle for press freedoms. My brother, Ali, an invited guest of my hometown congressman, Rep. Jared Huffman (D-Calif.), was somewhere in that crowd, still lobbying tirelessly for my freedom.

And I was thousands of miles away, watching the address unfold in radically different surroundings: inside a high-walled compound deep within Tehran’s Evin prison.

Watching Obama in Tehran

As The Washington Post’s correspondent in Tehran, I had been locked up for nearly 540 days at that point, detained on fabricated charges of espionage and “collaborating with hostile governments.” Since the moment my journalist wife and I were arrested in July 2014, there had been persistent calls for our release from a broad spectrum of leaders and influential figures in the United States and abroad.

Throughout the ordeal I was denied all my most basic rights: due process, access to legal representation, the opportunity to prepare a defense, bail. But although I was kept isolated from the general population of inmates — and the rest of the world — throughout my time in Evin, by January 2016 I had access to a television and someone to watch it with me.

The small, flat-screen panel was encased in a white wooden frame high on one of the walls. It received only the range of state-controlled channels and their heavily censored programming, and often I saw myself being slandered by Iranian officials and their propagandists. Yet the TV also gave me a window into what was happening in my home country.

It may seem odd that Iran, a declared enemy of the United States, would permit an American prisoner to watch the State of the Union. The annual address allows our president a unique opportunity to cast the United States in the best possible light, shaping viewers’ ideas around the world about what America can and should be, according to that administration’s agenda.

But the Islamic Republic’s state television covers American politics more closely — one might say religiously — than almost any other subject, and will often air live speeches by our presidents. American news, in fact, is an essential ingredient of the propaganda the regime creates to fortify its anti-Americanism.

So there I sat before dawn on the morning of Jan. 13 with my cellmate from a former Soviet republic, who spoke almost no English, but, like so many people around the world, had a fondness for the 44th president of the United States. Whenever Obama appeared on the small screen, he would put his hand to his chest and say “my friend” in Farsi.

I had found in years past that Obama could be counted on during the State of the Union to fulfill his role of inspiring hope that the country was on the right track. But that day in my Iranian prison cell, I watched as he foreshadowed our growing domestic identity crisis.

“When politicians insult Muslims, whether abroad or fellow citizens, when a mosque is vandalized, or a kid is called names, that doesn’t make us safer,” he said. “That’s not telling it like it is; it’s just wrong. It diminishes us in the eyes of the world. It makes it harder to achieve our goals.”

I knew that he was almost certainly referring to an incident several days earlier when a Muslim American named Rose Hamid was emphatically removed from a Trump campaign rally in South Carolina. All she had done was wear a T-shirt that read, “Salam, I come in peace.”

I knew this, even imprisoned, because Iran’s state television — like American cable news networks — had been giving incredible amounts of airtime to the American politician most likely to bash Islam, thus reinforcing Tehran’s narrative of America as being the “Great Satan.”

I listened closely to see whether Obama would mention me and the other Americans imprisoned in Iran. But he instead struck an optimistic chord.

“We built a global coalition, with sanctions and principled diplomacy, to prevent a nuclear-armed Iran. And as we speak, Iran has rolled back its nuclear program, shipped out its uranium stockpile and the world has avoided another war,” Obama said in his only reference to the Islamic Republic.

Although not mentioned in the speech, we had not been forgotten. Four days later, the other American prisoners and I were free. We were released on the same day that the landmark nuclear deal between Iran and world powers was implemented, but as we learned later, negotiations to release us in exchange for freeing Iranians imprisoned in America had been going on for over a year.

Huffman joined me, my wife, Yeganeh, Ali and my mother in Landstuhl, Germany, where two other Americans and I underwent post-release medical tests before flying back to the States. Huffman then invited Yeganeh and me to be his guests at the next State of the Union and we accepted with enthusiasm.

We could not have imagined at the time that Donald Trump would be the one giving the address, and that his message would be so vastly different from Obama’s.

Reasons for hope

I was pondering the epic turn of events for me, and for this country, when I entered the House chamber on Tuesday night. But those thoughts dissipated when Trump began his speech.

At times, he spoke in tones that often did not reflect the actions of his first weeks in office, adding to what was already a jarring experience for me.

“Each American generation passes the torch of truth, liberty and justice, in an unbroken chain all the way down to the present. That torch is now in our hands. And we will use it to light up the world,” Trump said.

But then I would hear again the strains that reminded me of so many speeches delivered by authoritarian leaders.

“The chorus became an earthquake, and the people turned out by the tens of millions, and they were all united by one very simple, but crucial demand, that America must put its own citizens first, because only then can we truly make America great again,” Trump said.

Like much of the American public, I had come to view Trump as a reactionary, and reactionary rhetoric provokes responses from other reactionaries. This is not a new dance, but the tempo is reaching new speeds, as leaders with no personal filters are taking to social media along with everyone else.

But Trump isn’t the only leader with a Twitter account, and right now in Tehran, and other capitals, anti-American leaders are licking their lips.

Iran’s supreme leader, Ayatollah Ali Khamenei, has one, too, and he has been using it to share his assessment of the White House’s newest occupant.

“We appreciate Trump! Because he largely did the job for us in revealing true face of America,” Khamenei tweeted on Feb. 7 on the heels of the executive order temporarily banning arrivals from seven predominantly Muslim countries, including Iran.

Since Yeganeh and I moved back to the United States, we have been welcomed by almost everyone we have encountered. But for us, along with millions of others in America, that feeling of security and belonging was rattled with Trump’s travel ban.

Then, earlier this month, Trump called another group that both my wife and I belong to “the enemy of the American people.” It was not some fringe opposition party he was referring to, but journalists, a community that she and I are proud to count ourselves among.

So in a plot twist worthy of fiction, we are now living in a situation in the United States with discomfiting parallels to our imprisonment in Iran, where we were condemned for practicing journalism and our ties to America. Yeganeh is a native of Iran who has recently come to a country that is showing increasing hostility to immigrants — especially those from Iran. And I am an American foreign correspondent whose profession is being slandered by some in my own country as un-American.

Like many Americans, I am apprehensive about Trump’s proposals, especially for residents of minority backgrounds and for journalists and our ability to do this job unimpeded by the state. Given his harsh words, my concerns feel justified.

Yet I remain fundamentally optimistic. I have lived and worked in an authoritarian country and have experienced firsthand what it means to be stripped of my liberties. The moment we are living through, alarming as it is, does not compare.

Trump and his administration may not properly value the ideals enshrined in our Constitution. But I believe the people of this country will not give them away easily. I am heartened as I observe so many other Americans, in Congress on Tuesday night for Trump’s address and around the country, refusing to accept this twisted vision of our future.

And I have so much more hope today than I did in early 2016. That is because I am here now, a free man in a free country, able to again use the tools of my trade to join in protecting and upholding the “liberty and justice for all” that we as Americans so rightly cherish.