BRUSSELS — The European Union’s fisheries agreement with Morocco has been cast into doubt after a top legal advisor said Wednesday that the pact is invalid because it does not respect the rights of people in the disputed Western Sahara region.

In an opinion for the European Court of Justice, Advocate General Melchior Wathelet said Western Sahara’s people have a right to self-determination and possible sovereignty over natural resources there.

Morocco considers the vast, mineral-rich Western Sahara as its “southern provinces” and fiercely defends against anything considered a threat to its territorial integrity. The territory’s status is one of the most sensitive topics in the North African kingdom.

Wathelet said that EU fishing in waters off the territory “does not respect the right of the people of Western Sahara to self-determination,” according to a statement from the ECJ.

He considers that the fishing agreement is incompatible with EU treaties that require the bloc’s actions abroad to protect human rights and strictly respect international law.

“The EU has failed to fulfil its obligation not to recognize the illegal situation resulting from the breach, by Morocco, of the right of the people of Western Sahara to self-determination and also not to render aid or assistance in maintaining that situation,” the statement said.

While not binding on the ECJ, such legal opinions are later adopted by the court in most cases.

The opinion follows an ECJ ruling on Dec. 21, 2016 that EU agreements on closer ties and trade with Morocco should not apply to Western Sahara.

The territory’s Polisario Front independence movement welcomed it as evidence that Western Sahara does not belong to Morocco, which annexed the former Spanish colony in 1975 and fought Polisario. The U.N. brokered a cease-fire in 1991 and established a peacekeeping mission to monitor it.

In 2015, the European court also annulled an EU-Morocco agricultural accord based on a complaint by Polisario that Western Sahara’s people should have been consulted first. That court ruling prompted protracted diplomatic tensions between the EU and Morocco, a key trade partner and ally on counter-terrorism and migration.