The European Court of Justice (ECJ) on Thursday said that migrants cannot be detained solely for staying illegally.

The ruling by the top court is linked to events last summer in Lithuania when several thousand people tried to cross into the European Union via Belarus.

The ECJ found that unless the EU country proves that the third-country national poses a threat to the national security, migrants cannot be detained for their lack of papers and the right to request asylum has to be granted even in emergency situations.

Lithuanian courts referred to the ECJ for clarification on the case of a non-EU citizen who was detained by Lithuanian authorities upon arrival and subsequently tried to apply for international protection.

The request, however, was rejected as Lithuanian law denies people arriving during a mass migration event the possibility to claim asylum.

READ ALSO: NCDC Deplores Misinformation About Monkeypox In Nigeria

The plaintiff’s detention was hence prolonged on the grounds of having entered the country without the necessary permits, against which the person appealed.

PRO ASYL, a German pro-immigration advocacy organisation, welcomed the ruling saying, in a press release, it shows that “pushbacks are illegal,’’ referring to a practice of forcing migrants out of the country without the possibility to apply for asylum.

Several human rights organisations have accused the Lithuanian authorities of having carried out pushbacks.

“The court has shown EU states some red lines,’’ said Karl Kopp, head of PRO ASYL’s European department, in the statement.

The Lithuanian courts can now rule on the pending case taking the ECJ’s judgement into account, which can also serve as a guideline for other national courts facing similar cases.

In a separate development, the Lithuanian government announced that it is to receive €55 million ($57 million) from the European Commission in financial aid to equip its entire border with Belarus with surveillance systems, the Interior Ministry in Vilnius announced on Thursday. (dpa/NAN)