Former military ruler Pervez Musharraf has been ordered held for two weeks until the next hearing in a case related to his 2007 decision to sack and detain several judges.
After the judge's order on Saturday, Islamabad's administration declared that Musharraf's lavish country residence could serve as a jail, meaning the ex-president could be held there under house arrest.
Musharraf appeared before the anti-terrorism court amid tight security, as hundreds of lawyers opposing him scuffled with security personnel and shouted slogans against the former military ruler.
The police had requested the administration that in jail there were serious security threats to Musharraf so he should be confined at his farmhouse
"Go Musharraf Go", "Countless curses on Musharraf", "Whosoever is a friend of Musharraf is a traitor," they shouted.
"Our lawyers denied the allegations that General Musharraf sacked judges and kept them and their families under house arrest for six months. It is absolutely untrue," Muhammad Amjad, spokesman for Musharraf's All Pakistan Muslim League party, told reporters.
"We had requested the court to send General Musharraf on judicial remand, so that we can go to higher courts for relief," he added.
He had spent the night at police headquarters in Islamabad, officials said, and was moved back there after his court appearance.
Musharraf has since been allowed to return to his farmhouse, saving him the hardships of a Pakistani prison where police said he would face "security threats".
"Islamabad administration has declared General Musharraf's house a sub-jail and he will be kept there during the remand period and all jail rules will apply to the building," a senior police official told AFP news agency.
"The police had requested the administration that in jail there were serious security threats to Musharraf so he should be confined at his farmhouse," the official said.
Musharraf was taken into police custody after being arrested on Friday ahead of key elections, an unprecedented move against a former army chief of staff.
Speaking to Al Jazeera, Raza Rumi of the Jinnah Institute, a Pakistan think-tank, called the development "unprecedented" in the country's history.
Six years ago, Musharraf declared a state of emergency and suspended the constitution.
He was concerned the judges would challenge his recent re-election as president, and cited the growing Taliban insurgency in the country as justification for the state of emergency.
Al Jazeera's Kamal Hyder, reporting from Islamabad, said the latest arrest was "just the tip of the iceberg".
"There are many cases against him," he said.
"They are indeed milestone cases, but no military ruler of Pakistan has ever been convicted in a court of law. It will be interesting to see what happens next."
Musharraf, who ruled Pakistan from 1999-2008, returned to the country last month from nearly four years of self-imposed exile in the hope of running in next month's general elections.
The elected prime minister he ousted, Nawaz Sharif, is now the front-runner in the general election campaign.
Musharraf's attempt to run for office has been rejected by election officials and he has instead found himself battling a host of legal challenges relating to his years in power.
Pakistan's top court is already hearing a petition demanding that Musharraf face trial for treason for imposing emergency law in 2007, punishable by death or life in prison.
He is also accused of conspiracy to murder opposition leader Benazir Bhutto in 2007 and over the death of a rebel leader during a 2006 military operation.
He had been granted bail repeatedly since his homecoming on March 24.
Musharraf's supporters say the latest arrest order was nothing more than a settling of scores for his dismissal of the judges.