A Pakistani court has remanded former president Pervez Musharraf in custody for two weeks over claims he illegally detained judges in 2007.
Judges plan to put the former army chief on trial for a crackdown on the judiciary during his time in office.
Hundreds of lawyers jeered at Mr Musharraf and scuffled with his supporters as he appeared at the Islamabad court a day after police arrested him at his home.
His arrest was a breach of an unwritten rule in Pakistan that ex-generals are above the law.
The judge ruled that he be detained until his next court appearance on 4 May.
However, Mr Musharraf's lawyers said it was not clear if the order meant he would have to go to jail or could be held under house arrest.
Mohammad Amjad, Mr Musharraf's spokesman, said he was hopeful the ex-paratrooper could serve his remand at his farmhouse.
His home is on the edge of Islamabad and paperwork to that effect was already being processed.
Mr Musharraf's appearance sparked chaotic scenes in the court complex.
Police formed a human chain to prevent protesting lawyers, who chanted "Down with Musharraf", from getting closer to the former president.
Mr Musharraf left the court after his brief appearance and returned to police headquarters, where he has been detained in a police guest house.
It is not clear if he will remain at the station or be transferred to another place of confinement.
He is facing allegations that he overstepped his powers in a showdown with the judiciary in 2007.
Mr Musharraf sacked the chief justice in 2007 and placed judges under house arrest.
His office issued a statement yesterday to say the allegations were baseless and politically motivated.
Mr Musharraf seized power in a coup in 1999, resigned in 2008 and went into self-imposed exile in London and Dubai.
He returned to Pakistan last month to try to stage a return to public life.
Mr Musharraf was attempting to run for a National Assembly seat in the 11 May parliamentary election, but election officers disqualified him.
Instead of triggering a hoped-for groundswell of popular support, Mr Musharraf became the first former army chief to be arrested in Pakistan when police took him into custody at their headquarters yesterday.