The protesters accused Prem of masterminding the September coup which ousted Thaksin.
Jakrapob Penkhair, a former Thaksin spokesman, refused to acknowledge the court decision, saying: "There is no justice in this country."
Police carried one protest leader, former judge Manit Jitchanklab, out in his chair after he refused to leave the courtroom.
Colonel Supisan Pakdeenarunart, a Bangkok metropolitan police spokesman, said the detention order meant that "the police need to finish investigation within 48 days before forwarding the case to the attorney-general's office".
The authorities must apply for a court order every 12 days to extend the detentions.
The increasing violence has been attributed to financial assistance from Thaksin.
Prasong Soonsiri, chief of the Constitution Drafting Committee and a former head of the National Security Council, said the funding was "coming in through various networks".
Thaksin denies such allegations, and earlier this week issued a call for peace and reconciliation.
On Sunday, six protesters were arrested for throwing rocks and bottles at the police during the rally, the first outbreak of violence since Thaksin's removal.
Following the rally, the army-appointed government said any future protests must be confined to Sanam Luang, a large parade ground fronting the Grand Palace in the capital, Bangkok.
Police have also been given orders to use force, including tear gas and batons, to disperse unruly demonstrations.
Boonrawd Somtas, the defence minister, warned parliament that the army would intervene by emergency decree or martial law if the police failed to control the situation.