BRUSSELS — A top European Union legal adviser denounced Hungary and Slovakia on Wednesday for refusing to participate in a plan devised in 2015 to relocate migrants from Greece and Italy as the migration crisis reached its height.

The legal adviser, Yves Bot, an advocate general for the Court of Justice of the European Union, blamed Hungary and Slovakia for “partial or total failure” in the “fair sharing of burdens” in the crisis, according to a summary of his opinion.

A verdict is still to be issued in the case, but judges usually follow their advisers’ opinions; if they do so this time, Hungary and Slovakia could eventually be ordered to pay fines.

The case has highlighted the deep divide in the European Union over the question of migration. Many member states in Central and Eastern Europe are intensely opposed to a push to oblige them to accept quotas of migrants from the Middle East and North Africa.