BUDAPEST (Reuters) – The European Union’s top court ruled on Tuesday that Hungary failed to fulfil its obligations under EU law with its rule that consider asylum applications inadmissible if the asylum seeker arrived to Hungary via a third country considered safe.

Secondly, the Court of Justice of the European Union found that Hungary also went against EU law by criminalising certain activities of providing assistance in making or lodging an application for asylum in its territory.

Budapest has lost a number of legal cases on migration at the EU’s top court since nationalist Prime Minister Viktor Orban adopted his hardline policies following a 2015 rise in Mediterranean arrivals that caught the EU by surprise.

Orban’s government had tightened asylum rules in the following years and has campaigned on a tough anti-immigration agenda, rejecting the notion of a multicultural society.

“First, the Court of Justice finds that Hungary has failed to fulfil its obligations… by allowing an application for international protection to be rejected as inadmissible on the grounds that the applicant arrived on its territory via a State in which that person was not exposed to persecution or a risk of serious harm, or in which a sufficient degree of protection is guaranteed,” the Court said in a statement.

It also said Hungarian legislation restricted the right of access to applicants for international protection and the right afforded to asylum seekers to be able to consult a legal adviser or other counsellor.

“The Court considers that such a restriction cannot be justified by the objectives relied on by the Hungarian legislature, namely the prevention of the assistance of misuse of the asylum procedure and of illegal immigration based on deception,” it said.

(Reporting by Krisztina Than; Editing by Catherine Evans and Alex Richardson)