Kenya's High Court on Friday suspended parts of the government's controversial new security law, rushed through parliament before Christmas, pending a full court hearing on whether the law violates the country's Bill of Rights.
Kenya's opposition and human rights groups are challenging the validity of the law, passed during an unruly session of parliament.
Justice George Odunga warned that new security laws must not limit freedoms enjoyed by Kenyans. The bill has been criticized for restricting the right to protest and forcing the media to get government permission before reporting on any counter-terrorist action.
One of the eight sections of the law he suspended called for imprisoning for up to three years members of the media who publish photographs of people killed or injured during terror attacks.
The judge said another section of the law, which would cut the current 500,000 Somali refugees allowed in Kenya to 150,000, contravened international law.
The law also requires anyone planning a protest rally must get permission from the cabinet secretary in charge of security.
He said the right to a fair trial for all suspects must be jealously guarded by courts.
"Our country has been the victim of an undeclared war and we need new techniques and laws to eradicate the menace," he said.