Kenya's President Uhuru Kenyatta has signed into law a controversial security bill which saw MPs trade blows in parliament.
It was passed on Thursday during a chaotic parliamentary session, with opposition MPs warning that Kenya was becoming a "police state".
The government has said it needs more powers to fight militant Islamists threatening Kenya's security.
Somalia's al-Qaeda-linked al-Shabab group has stepped up attacks in Kenya.
The new anti-terror legislation requires journalists to obtain police permission before investigating or publishing stories on domestic terrorism and security issues.
It also stipulates that police must approve publication or broadcasting of information relating to investigations on terrorism.
"We must all remember that we are still at war and still vulnerable to terror attacks," Mr Kenyatta said in a televised address, defending the law.
He denied that it infringed on civil liberties.
The BBC's Dennis Okari in the capital, Nairobi, says the security bill has gone through various amendments.
The provision giving the security and intelligence agencies power to intercept phone conversations without a court order was dropped, he says.
A court order must be sought to hold terror suspects within 24 hours, after which they can be held for 360 days, up from the previous period of 90 days.
- Bans publishing or broadcasting of "insulting, threatening, or inciting material", images of dead or injured people "likely to cause fear" and information that undermines security operations (this covers social media). Punishable by a fine of $55,000, a three-year jail term or both
- Terror suspects can be held for questioning for 360 days
- Limits number of refugees and asylum seekers to 150,000 - those applying for refugee status not allowed to leave camps
- Sets up National Counter-Terrorism Centre to co-ordinate security agencies' efforts
- Public officials found guilty issuing irregular IDs or allowing irregular entry into the country liable to a minimum of 15 years in jail
- Person in charge of a premises where weapons recovered may face up to 30 years in prison
- Person promoting ideology based on violence to advance political, religious or social change may face up to 14 years in jail
- Person who forcibly strips someone is liable to a minimum of 10 years in prison
The opposition, civil society groups and the media have all said they will go to court to challenge the legislation.
The legislation also included a clause providing for a minimum of 10 years in prison to anyone convicted of forcibly undressing someone.
This follows several incidents of women have their clothes ripped off and being sexually abused by a group of men in public.
Thursday's special parliamentary sitting, which turned into mayhem live on television, shocked many Kenyans, our correspondent says.
Opposition MPs tore up papers and chanted anti-government slogans - there was a fist-fight and the deputy speaker had water poured over her.
Mr Kenyatta condemned their behaviour as "deplorable" and said the law was only meant to "protect the lives and property of all Kenyans and disrupt any threats to our national security".
"May peace dwell within our borders during this festive season," he said at the end of his address.
Since last month, al-Shabab has killed 64 people in two attacks in the north-eastern region of Mandera, which borders Somalia. Last year it was also responsible for the Westgate shopping centre siege in Nairobi in which 67 people died.
Kenya sent troops into Somalia three years ago, and they now make up part of the African Union force helping to fight the militant group.
Correction 5 January: We have amended this story to remove reference to a clause allowing terror suspects to be detained for a year, as this was altered before the bill was passed by parliament.