The EU's top court has ruled that refugees who claim asylum on the grounds that they are homosexual should not have to undergo tests to prove it.
Three men, including a Ugandan and one from a Muslim country, failed in their bids for asylum when a Dutch court said they had not proved their sexuality.
EU states including the UK have been criticised for their handling of gay asylum requests.
The European Court of Justice (ECJ) says they must respect human dignity.
Its rulings apply to all EU member states.
The case is significant across the EU because of a surge in the numbers of sub-Saharan Africans seeking asylum in Europe this year. Most African countries treat homosexuality as a crime.
The Czech authorities were criticised by the UN, EU and human rights activists in 2011 for using an erection or "phallometric" test - a practice dating back to communist times - to determine whether certain asylum seekers were gay.
In its latest ruling, the Luxembourg-based court said that determining a refugee's sexuality had to be consistent with EU law and respect their private and family life.
In particular, it said that evidence of homosexual acts submitted from tests or on film infringed human dignity, even if it was proposed by the asylum applicant. Allowing such evidence could result in it becoming a requirement, the court said.
While authorities could interview an asylum seeker to find out about their sexual orientation, questions could not be asked about their sexual practices.
An asylum seeker's failure to answer questions about their personal circumstances was not sufficient reason to reject their credibility. Nor was an applicant's failure to declare his homosexuality from the start, the judges said.
Treatment of gay, lesbian or bisexual refugees has become a key issue in the UK in recent months, after revelations that one asylum seeker was asked what one lawyer described as "shockingly degrading" questions.
A report by the UK independent chief inspector of borders and immigration in October found that more than one in 10 interviews involved questions of an "unsatisfactory nature".
The ECJ ruled last year that gay asylum seekers who had a genuine fear of imprisonment in African countries could claim refugee status, in response to another Dutch case.