On Saturday, Iran and Sweden exchanged prisoners. The swap had the appearance of any two countries engaged in diplomatic negotiations to free their citizens. Families were elated; governments were relieved.

But the exchange was only the latest chapter in Iran’s long history of what is known in world affairs as hostage diplomacy.

For more than four decades, since the 1979 revolution that installed a conservative theocracy, the country has made the detention of foreign and dual nationals central to its foreign policy. For Iran, the approach has paid off. For the world, it has been a troubling trend.

Iran’s demands have evolved along with its tactics. In exchange for releasing foreigners it has asked for prisoners, assassins, cash and frozen funds. It has engineered complex deals involving multiple countries. And on Saturday Iran gained the release of its most prized target: the first Iranian official to be convicted of crimes against humanity.

In the exchange, Sweden released Hamid Nouri, a former judiciary official who was serving a life sentence in Sweden for his role in the mass execution of 5,000 dissidents in 1988.

In return, Iran freed two Swedish citizens — Johan Floderus, a diplomat for the European Union, and Saeed Azizi, a dual national Iranian. A third, a Swedish dual national scientist, Ahmadreza Djalali, who has been jailed in Iran and sentenced to execution on murky charges of treason, was left behind.