Gays can seek asylum in the European Union when threatened with jail for same-sex activity, but only when such persecution is "sufficiently serious", Europe's top court ruled on Thursday.

The judgement by the Luxembourg-based European Court of Justice was seen as divisive, with rights groups differing widely in their reading of what this could mean in practice.

The court found that jail terms for homosexual behaviour could be considered "an act of persecution" warranting asylum.

But it said the threat of persecution must be enforced and "sufficiently serious" with courts in home countries regularly throwing people behind bars.

European lawmakers dubbed the ruling a breakthrough.

But Amnesty International saw it differently, deeming it "a setback" for gay rights.

The court had been asked to consider a case referred by a Dutch court regarding applications for asylum by three men from Sierra Leone, Uganda and Senegal, who all asked for refugee status on the grounds of sexual persecution.

"The existence of a term of imprisonment in the country of origin sanctioning homosexual acts may constitute an act of persecution per se, provided that it is actually applied," the judges ruled.

They also said that the persecution endured by applicants claiming sexual discrimination must be "sufficiently serious by their nature or repetition" to be considered as "a severe violation of basic human rights".

The European Union recognises minimum standards for refugee status based on the violation of fundamental rights. But it is up to individual nations to assess applications as well as judge whether the conditions in the country of origin are harsh enough to merit granting asylum.

Under the ruling, a gay applicant would have to show he or she was "unable or, owing to such fear, is unwilling to avail himself of the protection of that country".

The head of a European Parliament group on lesbian, gay, bisexual and transgender rights, British Socialist MEP Michael Cashman, said the court had reached a "landmark decision, and the right one".

He said governments now had clear guidance and should act "so that our asylum procedures become more accommodating of the terrible realities people flee".

But Amnesty International said judges had "skirted around" the realities and called the ruling a "missed opportunity".

More than 70 countries still make being gay or lesbian a crime.

According to a 2013 map on gay and lesbian rights produced by the International Lesbian, Gay, Bisexual, Trans and Intersex Association (ILGA), Sierra Leone and Uganda enforce prison terms of up to a life sentence for gays, while Senegal imposes terms up to 14 years.

Countries that apply the death penalty include Mauritania, Sudan and parts of Nigeria and Somalia, the ILGA says.

However, the room for maneouvre left with national authorities within the EU when assessing asylum applications on such grounds is likely to mean different answers in different EU states.

"The court should have found that these laws, even when they have not recently been applied in practice are capable of giving rise to a well-founded fear of persecution," said Livio Zilli, senior legal adviser at the International Commission of Jurists, in the Amnesty statement.

As well as leaving scope for different treatment across the EU's 28 member states, the court also said it was "not reasonable" for asylum seekers to have concealed their homosexuality in their countries of origin if pressing claims on the grounds of persecution.