Hungary, which has long called for stricter policies on European migration, had expressed concerns over the agreement during negotiations. Mr. Szijjarto said the accord did not address the “fundamental human rights of people who want nothing else than to be able to live in peace and security in their own homelands.”

At least 258 million people worldwide can be classified as migrants, according to the United Nations, and that number will grow in coming years. Unlike refugees, who are offered protections under international law, migrants often find themselves without legal rights in the countries they enter, if they do so illegally.

At least 60,000 people migrating internationally have died since 2000 while crossing the sea, while traveling through inhospitable areas, while being held in detention or under other circumstances. The negotiators of the agreement say they were driven by the need to protect members of a vulnerable population who are often demonized and attacked.

The compact itself was driven in part by the 2015 crisis that saw European nations struggle to cope with large numbers of migrants entering the Continent. While the number of new arrivals has dropped significantly, the debate about migration has grown heated in Europe. The rise of anti-immigration, populist governments in Italy, Austria and Hungary has added fuel to the debate.

Amina J. Mohammed, the United Nations deputy secretary general, speaking after the agreement was announced on Friday, said the compact was intended to foster global collaboration.