Kenya has ordered all urban-based Somali refugees to move into designated camps in a bid to end attacks by militant Islamists.
Interior Minister Joseph Ole Lenku said the directive had been issued because of the "emergency security challenges" facing Kenya.
A refugee group condemned the decision as illegal.
Somalia's al-Qaeda-linked al-Shabab group has carried out a spate of attacks in Kenya in recent years.
It was behind the four-day siege at the Westgate shopping centre in Nairobi in September in which 67 people died.
'Harassment and extortion'
On Sunday, at least six people were killed when gunmen opened fire on a church near the coastal city of Mombasa.
No group said it carried out the attack.
Kenya has repeatedly claimed that refugees crossing over from Somalia are threatening its security.
Mr Ole Lenku said refugee registration centres in Kenya's main cities would be closed.
All refugees living in cities and towns should report to the Dadaab and Kakuma camps in eastern and north-western Kenya, he added.
"Any refugee found flouting this directive will be dealt with in accordance with the law," Mr Ole Lenku added in a statement.
The BBC's Abdullahi Abdi in Nairobi says the decision will affect hundreds of thousands of Somalis - many of whom live and work in cities - and could worsen overcrowding at the camps.
Around half a million refugees live in Dadaab and more than 100,000 in Kakuma.
The US-based Refugees International (RI) group said the government should immediately withdraw the directive.
"Kenya has signed international conventions that allow freedom of movement for refugees, and Tuesday's decision flies in the face of those assurances," the group said in a statement.
A similar decision in 2012 was declared unconstitutional by the Kenyan High Court, but not before it sparked violence, harassment, and extortion against refugees at the hands of the security services, RI said.
"For years, Kenya was a generous host to Somali refugees, permitting many to become self-sufficient and contribute to the country's economy and society. This decision marks a disturbing shift in the wrong direction, and it should not stand," it added.