KABUL, Afghanistan — President Hamid Karzai abruptly demanded on Thursday that the American-led coalition hand over all Afghan prisoners in its custody and cede control of its main prison in Afghanistan within a month. He said that his government had evidence that Afghan law and prisoners’ human rights were being violated at the prison.

The demand stunned the coalition leaders, who were not consulted before the announcement, according to American and European officials in Kabul.

The coalition has longstanding plans to turn over the prison to Afghan authorities, along with control over all detainees, but the timing has remained uncertain because of delays in training Afghan guards to run the facility and because of concerns about widespread torture and other abuses in Afghan-run prisons.

In contrast, independent Afghan and Western human rights advocates have documented relatively humane conditions at the American prison since it opened in late 2009, replacing an older facility that was plagued by abuses. Even so, there have been persistent complaints about arbitrary detentions and a lack of due process at the new prison — problems that are pervasive in the Afghan prison system as well.