United Nations Secretary-General Ban Ki-moon urged Dominican legislators on Wednesday to find a humanitarian solution to a fiercely debated court decision that could render thousands of people of Haitian descent stateless.

Ban spoke to the Caribbean country’s bicameral legislature a day after meeting with President Danilo Medina.

“It won’t be easy,” he said. “This requires compromise and tough consultations. It requires your compassion as human beings and as leaders of this country.”

The Dominican Republic recently passed a law that would create a path to citizenship for the descendants of tens of thousands of migrants who came from neighbouring Haiti. But human rights groups have said the law will likely exclude the majority of people born in the Dominican Republic to migrants, leaving them essentially stateless.

Ban asked that legislators keep working to protect the rights of all people and prevent what he called “the privatization of nationality.”

Some lawmakers bristled at Ban’s comments.

“He thinks Dominican nationality belongs to the Haitians who claim they were born here,” legislator Vinicio Castillo said, calling the speech interference in Dominican affairs.

Reinaldo Pared, president of the Senate, said the government is trying to control a serious migration problem.