Russian anti-Putin campaigner Alexei Navalny has denounced his detention as "blatantly illegal" in an appeal hearing via video link.
A judge heard, and then rejected, his appeal against detention for 30 days.
He was arrested on 17 January for not complying with a suspended sentence. He had only just arrived from Berlin, where he spent months recovering from a near-fatal Russian nerve agent attack.
Thousands of Navalny supporters protested across Russia last Saturday.
The authorities say he was supposed to report to police regularly because of a suspended sentence for embezzlement.
But his lawyers called this "absurd", saying the authorities knew he was being treated in Berlin for the Novichok poisoning, which happened in Russia last August.
Mr Navalny, Russia's most prominent opposition leader, told the judge on Thursday "this is all massively, blatantly illegal".
His lawyers protested that Mr Navalny's hasty trial at a police station on 18 January had lacked transparency and that they had been denied access to him.
Mr Navalny also complained he had not been allowed to speak to his lawyers in private since his arrest. Then the judge did allow that to happen briefly.
Police crackdownPolice have arrested some of his top aides, including lawyer Lyubov Sobol and his brother Oleg.
Two other aides - his spokeswoman Kira Yarmysh and anti-corruption investigator Georgi Alburov - were escorted back to their homes to witness police searches, then returned to detention.
Mr Navalny's doctor Anastasia Vasilyeva was among those whose flats were raided by police on Thursday.
A video clip shows her defiantly playing the piano while a police officer reads out an official document, demanding that she sign it.
Mr Navalny accuses President Vladimir Putin of running an administration full of "thieves". Mr Putin refuses to name him in public and belittles him as simply a "blogger".
The campaigner's Anti-Corruption Foundation (FBK) has urged supporters to rally again on Sunday. The wave of arrests is linked to last Saturday's unauthorised rallies. One of the accusations is that children are being drawn to them via social media.
In the appeal hearing, Mr Navalny blamed his treatment on "those who want to shut me up - to scare me and everyone else."
"You want to show you're the bosses of this country. But you are not. You have the power now, but that's not eternal."
He said the protesters and his team facing criminal charges and having their homes searched were the real patriots of Russia - and the majority.
Mr Navalny blamed state security agents under Mr Putin's orders for the Novichok attack which nearly killed him. Investigative journalists in the Bellingcat team have named Russian FSB agents suspected of the poisoning.
The Kremlin denies involvement and disputes the conclusion, by Western weapons experts, that Novichok was used.