(Reuters) - In a year of heightened tensions between Iran and the United States that brought the longtime foes to the brink of military conflict, a swap of prisoners on Saturday was a rare act of cooperation.

The two countries have been enemies for 40 years, ever since hardline Iranian students stormed the U.S. embassy in Tehran soon after the fall of the U.S.-backed shah, and 52 Americans were held hostage there for 444 days.

Here is how Iran-U.S. ties hit a new low point in 2019:

TRUMP EXITS NUCLEAR ACCORD

In May 2018, U.S. President Donald Trump withdrew from a 2015 nuclear agreement between Iran and world powers.

Under the advice of hardliners in his administration, Trump said the accord was flawed and he sought a new one that would further curb Iran’s nuclear program, halt its ballistic missile work and end its support for proxy forces in the Middle East.

Trump reimposed crippling economic sanctions on Iran, including its vital oil exports, as part of a “maximum pressure” policy.

Iran said it would not negotiate a new accord until sanctions were lifted and urged European parties to the pact to help protect Iran from the economic damage. European efforts to salvage the agreement have been complicated by Iran’s steps to reduce its commitments under the accord.

SUMMER OF MILITARY TENSIONS

Tensions flared around the Gulf and Strait of Hormuz, a main conduit for oil supplies, in May and June after attacks on oil tankers that the United States blamed on Iran and which Iran denied.

Last June, Trump aborted a military strike to retaliate for Iran’s downing of an unmanned U.S. drone because, he said, it could have killed 150 people. Trump signaled he was open to talks with Tehran.

Tensions rose anew after a pre-dawn Sept. 14 drone and missile attack on Saudi oil facilities that temporarily crippled much of the kingdom’s production capacity. The United States blamed Iran for the attack on its ally, describing it as an “act of war.” Iran denied involvement. The United States sent new troops to Saudi Arabia.

A CHANCE TO TALK

Despite the severity of the Saudi attack, days later French President Emmanuel Macron and British Prime Minister Boris Johnson teamed up to urge Iranian President Hassan Rouhani to meet Trump while they were all in New York for the U.N. General Assembly. Trump, who basks in high-profile summits, had said he was willing to meet Rouhani in New York without preconditions.

But the meeting never materialized, as neither antagonist showed much desire to discuss the many issues dividing them, from Iran’s reawakening nuclear program to the U.S. sanctions squeezing the Iranian economy.

The U.S. tone, however, was more conciliatory than it had been, with Iran hawk Secretary of State Mike Pompeo saying at the time “We want a peaceful resolution with the Islamic Republic of Iran.”

WORKING ON PRISONER SWAPS

In June, Iran had released Nizar Zakka, a Lebanese businessman with U.S. permanent residency, after four years in prison, a goodwill gesture by Tehran to cool tensions, sources told Reuters. It was meant as an opening for U.S.-Iranian talks, but the United States failed to act upon it.

In late September, the United States said it had been reaching out to Iranian officials to discuss the fate of American nationals held in the Islamic republic and had sent a letter earlier in the year.

On Saturday, Iran released Xiyue Wang, a U.S. citizen who had been held for three years on spying charges, while the United States freed Iranian Massoud Soleimani. He had been facing charges of violating U.S. sanctions against Tehran.

A senior U.S. official said Washington was hopeful that Wang’s release would lead to the freeing of other Americans held in Iran and that it was a sign Tehran was willing to discuss other matters.