Viktor Orban, who has recently commissioned a new task force of “border hunters” to capture illegal migrants, wants any asylum seeker who passed through a safe country en route to Hungary to be shipped back there as soon as possible.
Migrants will be kept in converted shipping containers and will have to pay for their own detention.
The law states that any asylum seekers, including families with children and unaccompanied older than 14-years-old to be jailed.
They will have just three days to appeal against their deportation.
Mr Orban, who fronts up the right wing Fidesz party, has reinforced Hungary’s border defence systems, such as high-rise fences, as well as boosting the number of dedicated migrant-focussed police.
But the move has come under sharp criticism from the UN Refugee Agency, which says it is “deeply concerned” about Mr Orban’s new law because it makes it “nearly impossible for asylum-seekers to enter the country, apply for asylum and receive international protection”.
Spokesperson for the UNHCR, Cécile Pouilly, said: “This new law violates Hungary’s obligations under international and EU laws, and will have a terrible physical and psychological impact on women, children and men who have already greatly suffered.
“Under international and EU laws, the detention of refugees and asylum-seekers can only be justified on a limited number of grounds, and only where it is necessary, reasonable and proportionate… children should never be detained under any conditions.”
Hungary initially ditched its policy of detaining migrants after coming under pressure from the EU, but Mr Orban feels numbers have got too high and the policy must be brought back into action.
Migrants have made allegations of abuse against Hungarian police, but Mr Orban’s spokesperson said authorities were “carrying out their duties lawfully, professionally and proportionately” in a manner which showed “respect for their human dignity”.