KABUL, Afghanistan — A week of talks between the Afghan government and the Taliban on a prisoner swap — seen as crucial to preserving a fragile peace deal between the insurgents and the United States — appeared to be collapsing on Tuesday, as Taliban leaders ordered their team to pull out of the discussions.

An agreement signed between the United States and the Taliban in February that started the withdrawal of American troops from Afghanistan calls for the swap of thousands of prisoners before the two Afghan sides sit together for talks over a future power-sharing. But the prisoner swap, which was to be done in batches, has faced opposition and hurdles all along, threatening the unraveling of a deal that the Trump administration hoped would signal the end of America’s longest war.

After weeks of pressure from American diplomats, the government of President Ashraf Ghani agreed to a phased release of 5,000 Taliban prisoners. In an unprecedented move, a small technical team of the insurgents arrived in Kabul for discussions with Afghan officials over verification of identities before the release. But those technical discussions now appear to have collapsed after a week as each side accused the other of insincerity.