Israel's high court on Monday outlawed a detention center where African migrants are held without trial and ordered some 2,000 inmates there released over the next three months.

The ruling struck down a measure passed by Israel's parliament in December to indefinitely incarcerate migrants, most of them from Sudan and Eritrea, in a measure criticized by human rights groups as an attempt to force migrants to leave.

Israeli leaders have denounced the migrants they refer to as "infiltrators" as harmful to Israel, and largely stopped their entry by fortifying a fence along the Egyptian border in 2012, later offering financial incentives to those agreeing to leave, and detaining thousands.

In their groundbreaking decision acting on appeals by human rights groups, Israeli justices ordered authorities to shut a detention center called Holot opened a year ago in the southern Negev desert, and release some 2,000 Africans being held there.

The decision gives Israel three months to implement the ruling, but orders an immediate liberalisation of rules for Holot inmates effective on Wednesday, by allowing them to report to wardens twice rather than three times a day.

Justice Uzi Vogelman, one of seven of nine justices finding against the detention center, wrote that the "measure is disproportionate and unconstitutional and there is no choice under the circumstances but to order the law cancelled."

Rights to Freedom and Dignity

"There is almost no right that isn't violated as a result [of incarceration]. It negates one's right to freedom and hurts one's right to dignity," Vogelman also said, according to a summary of the ruling issued by Israel's courts authority.

More than 40,000 Eritreans and Sudanese are in Israel, human rights groups say based on Israeli population figures. Many had entered Israel illegally since 2011.

More than 6,700 of the Africans have left the country since January, shortly after Israel opened the detention center the court has now outlawed.

The court addressed only the incarceration policy, which was the subject of the appeals, and did not mandate any status for migrants being freed, who may be eligible for temporary permits given other migrants which must be renewed every few months.

Israel grants automatic citizenship to Jews, while denying refugee or residency status to many others. Some social activists complain this policy is discriminatory while others cite a shortage of legislation governing immigration.

Human Rights Watch charged in a report this month that by jailing migrants Israel was coercing people entitled to refugee protection under international law to risk their lives through repatriation.

Israeli Interior Minister Gideon Sa'ar, who oversees the detention center, denounced the ruling as "a mistake that leaves Israel without the tools to handle illegal infiltration." He urged the government to consider amending a law to restrict the courts' authority to intervene in such policies.

The ruling was the second since a year ago to tackle Israel's tough policies toward the migrants. In September 2013 justices overruled legislation that permitted migrants to be jailed for terms of up to three years without trial.

Hotline for Refugees and Migrants, an Israeli advocacy group, praised the court for finding "in a categorical and unequivocal manner that policy toward asylum-seekers can not be solely based on mass detention of innocent people."