For instance, a Yemeni man resettled in Serbia in 2016 has struggled to learn the local language while complaining that a Guantánamo stigma was wrecking his job and social-life prospects. He was resettled alongside a former detainee from Tajikistan, who has more readily adapted. But both lack legal status, and a Serbian official told one of their lawyers that the government is reviewing whether to deport them this summer, after the two-year travel ban ends. A government spokesman said no decision has been made.

Beth Jacob, the Yemeni’s lawyer, said her client fears repatriation but she could “not even find someone in the U.S. government to discuss our concerns with.” And Matthew O’Hara, a lawyer for the other former detainee, said his client would likely be persecuted or tortured in Tajikistan, which revoked his citizenship. “My level of concern went through the roof when I saw what happened in Senegal,” he said.

Senegal took in the two former detainees from Libya in April 2016 as a favor to Mr. Obama by its president, Macky Sall. The two men, Salem Abdul Salem Ghereby and Awad Khalifa, were given apartments in Dakar, with a minder living nearby.

When a Times reporter visited the men on April 3, Mr. Ghereby complained that Senegal would not permit his wife and children from Libya to come stay with him. Both wanted larger grocery rations. But there were also signs the resettlement was working. Mr. Khalifa, for example, was warmly greeted by his neighbors and said he was engaged.

Senegalese officials have refused to discuss what prompted them to consider deporting the men. Relations between African countries and the United States have generally deteriorated under Mr. Trump, especially since reports surfaced in January that he insulted African nations using a crude term.

Ramzi Kassem, a law professor at the City University of New York who is represents Mr. Khalifa, said his client was first told in January he might not be allowed to stay in Senegal. Mr. Kassem emailed the United States Embassy but received no reply. On March 26, the men were told in writing they would be deported.

While Mr. Ghereby apparently did not object because at least in Libya he could be reunited with his family, Mr. Khalifa was terrified, telling a Times reporter that he feared he would be killed. Hours after that interview, neighbors said, Senegalese security officials took the men away.