In a rare prisoner swap, the authoritarian government in Caracas has released several Americans imprisoned in Venezuela for years.

In return, the American authorities released two relatives of Venezuelan President Nicolás Maduro who had been convicted in the United States.

US President Joe Biden and Secretary of State Antony Blinken announced the release on Saturday.

The exchange for two of Maduro's wife's nephews was confirmed by a White House official.

Most of the seven released are former oil managers of Citgo, the American subsidiary of the state-owned Venezuelan oil company PDVSA.

They were arrested in Venezuela in 2017 and sentenced to long prison terms in a corruption trial in 2020.

Six of those released are American citizens and one is a permanent resident of the United States.

The American government criticized the trial against the "Citgo 6" as politically motivated and unfair.

One of the six Citgo executives originally convicted was released in March following talks between the United States and Venezuela.

At the time, observers saw the release as a gesture of goodwill on the part of Maduro.

The Venezuelan government confirmed the exchange.

"We want to inform our people and the international community that after a series of discussions with the US government, we have secured the release of two unlawfully detained young men," the government said in a statement.

"Additionally, the judicial authorities have decided to release a group of convicted American citizens on humanitarian grounds."

The United States had been trying for years to free the remaining five Citgo managers and other Americans, including a Marine veteran.

When it became clear that this could be achieved by pardoning Maduro's wife's two nephews, President Biden made the "difficult decision" to grant the wish, said the senior official in the US government.

He emphasized that such steps would remain a rare exception: "To assume otherwise would be a wrong conclusion from it."

The nephews of Venezuela's First Lady Cilia Flores were each sentenced to 18 years in prison for drug trafficking in the United States in 2017.

Franqui Flores and Efraín Campo were arrested in Haiti in 2015 and extradited to the United States for attempting to smuggle large quantities of cocaine into the United States.

According to the investigators, they were not particularly skillful.

At the time, given the tensions between Washington and Caracas, Maduro said it was a political action by the United States to attack his wife.

Against the background of the Russian war of aggression in Ukraine, there had recently been talks between representatives of the American and Maduro governments in Venezuela.

Although the United States has also imposed numerous sanctions on Venezuela, Venezuela, which is quite close to the United States, has the largest oil reserves in the world.

The United States has banned imports of Russian oil over the attack on Ukraine.

Alongside Cuba and Nicaragua, Venezuela is one of Russia's closest allies in Latin America, but it also wants to boost its ailing oil economy.