Two other Americans — Mr. Heath, who was detained in 2020, and Mr. Khan, who was detained at the beginning of this year — were also among those released by Venezuela on Saturday.

Asked whether the release of the Venezuelan drug smugglers would prompt Mr. Maduro to detain more Americans, the senior administration official said he hoped that the Venezuelan president and others would realize that the president’s decision was a “rare” action that is not likely to be repeated often.

Senator Marco Rubio, Republican of Florida, lashed out at the administration on Twitter.

“Today Biden released two convicted drug dealer nephews of #Venezuela dictator Maduro in exchange for 7 innocent Americans being held hostage,” said Mr. Rubio, whose state is home to many Venezuelans who fled the socialist governments there.

“Another Biden appeasement that will result in more anti-U.S. dictators taking more innocent Americans hostage in the future,” Mr. Rubio wrote.

In Iran, it was unclear what had prompted the release of the Namazis.

“We’ve been working on a furlough for years, he would be eligible for furlough after he served more than half his term. This has been long coming,” said Jared Genser, the pro bono lawyer for the Namazi family. “We are not there yet, we are not going to rest until all the Namazis are able to return to the U.S. and their long nightmare finally comes to an end.”

Mr. Genser said the younger Mr. Namazi’s furlough, while renewable, lasts for just seven days. “He still needs to be able to leave Iran and return to the United States,” Mr. Genser said. “We hope and pray that will happen soon, but there has been no agreement between the U.S. and Iran to release all the American hostages.”

António Guterres, the secretary general of the United Nations, said in a statement on Saturday that he was grateful that the elder Mr. Namazi, a former senior official for UNICEF, had been permitted to leave Iran for medical treatment abroad following Mr. Guterres’s appeal to President Ebrahim Raisi of Iran.