MARRAKECH, Morocco (AP) — Defying fierce opposition from the U.S. and a few other nations, nearly 85 percent of U.N. member states agreed Monday on a sweeping yet non-binding accord to ensure safe, orderly and humane migration.

The debate over the Global Compact for Migration, the first of its kind, has proven to be a pivotal test of the U.N.-led effort to crack down on the often dangerous and illegal movements across borders that have turned people smuggling into a worldwide industry, and give people seeking economic opportunity a chance.

“Unregulated migration bears a terrible human cost: a cost in lives lost on perilous journeys across deserts, oceans and rivers; and a cost in lives ruined at the hands of smugglers, unscrupulous employers and other predators,” U.N. Secretary-General Antonio Guterres told a migration conference in Marrakech, Morocco.

“More than 60,000 migrants have died on the move since the year 2000,” he said. “This is a source of collective shame.”

Migration affects hundreds of millions of people across the globe — farmers coming off the land or forced by climate change to head to cities, families fleeing war or persecution at home, impoverished workers from the developing world looking for jobs in rich countries. It can also involve high-skilled workers from developed nations looking for opportunities beyond their homelands.

Defenders say migration greases the wheels of the world economy by diversifying and rejuvenating workforce in aging rich countries and providing a needed source of cash to poorer countries through remittances sent home by migrants.

Opponents often fear that an influx of migrants can dilute their countries’ character, import poverty or crime, reduce wages and take jobs from tax-paying citizens.

A total of 164 countries among the 193 U.N. members approved the agreement by acclamation Monday. The U.N. General Assembly will meet on Dec. 19 to endorse it.

At the two-day conference, U.N. leaders were hoping to lure in holdouts from mostly Western nations who were not signing: Australia, Austria, the Czech Republic, the Dominican Republic, Hungary, Latvia, Poland and Slovakia along with the United States, which under President Donald Trump did not participate in drafting the accord.

Louise Arbour of Canada, a former U.N. human rights chief, said the issue also has been tied up in parliamentary debates in Belgium, Bulgaria, Estonia, Italy, Israel, Slovenia and Switzerland — although some of them did participate in creating the accord, which has since been ensnared by tough political headwinds.

The conference is the capstone of efforts set in motion two years ago when all 193 U.N. member states, including the U.S. under President Barack Obama, adopted a declaration saying that no country can manage international migration on its own and agreed to work on a global compact.

The U.N.’s International Organization for Migration defines migrants as anyone working or living far from home. It says every refugee — people who flee persecution in places like Myanmar or Syria — is a migrant. Unlike refugees, some migrants can be motivated by economic opportunity, and many of those head to rich, developed countries in the West or the Persian Gulf.

The Trump administration — which is demanding a wall on the Mexican border and has sent U.S. military troops to the border to block a migrant caravan moving toward the U.S. through Central America — pulled out of the accord a year ago. It claimed that parts of the compact clashed with “U.S. immigration and refugee policies.”

Some European Union countries, including Italy, Poland and Hungary, now have anti-migrant populist governments that have reacted strongly after over 1 million migrants — mostly refugees fleeing conflict in Syria, Iraq and Afghanistan — poured into Europe in 2015.

Proponents of the compact decried “false information,” such as the claim it will force countries to legalize immigration.

Defenders of the pact simply want to remind some politicians and countries that migrants are people too, and have human rights. The U.N. was also celebrating the 70th anniversary of the Universal Declaration on Human Rights on Monday.

“The easiest fear to stoke up is the fear of the foreigner,” U.N. human rights office spokesman Rupert Colville said.