KABUL, Afghanistan — President Ashraf Ghani of Afghanistan on Wednesday ordered the phased release of thousands of imprisoned Taliban fighters, caving in on an earlier refusal that was threatening to derail the next steps of the American negotiated peace plan for the country.

Mr. Ghani’s government was furious when — as part of the deal signed last month between the United States and the Taliban laying out the American troop withdrawal from Afghanistan — the Americans had agreed to push for the release of as many as 5,000 Taliban prisoners.

Officials for Mr. Ghani repeatedly said that the Afghan government had the sole authority to release the prisoners, and that it would not agree to such a risky move as a precondition for the next step in the peace process: direct talks between the Taliban and Afghan leaders over the political future of the country.