Asylum seekers must not be forced to take psychological tests to determine their sexuality, Europe's top court has ruled.
The highly controversial practice has been used in the past on asylum seekers who claim to have fled persecution because of their sexuality.
Homosexual acts are illegal in many African nations, including Uganda, Nigeria, Kenya and Botswana.
The European Court of Justice ruled on Thursday (25 January) that psychological tests on gay asylum seekers to prove their homosexuality were illegal. The ruling is binding in all 28 EU states.
The ECJ made the ruling after an appeal brought by a Nigerian man against a Hungarian court decision to deny him asylum after psychological tests determined that he was not gay.
His request to remain in Hungary is likely to be bolstered by the decision of the EU judges, although the eastern European country is known for its hardline approach to immigration.
In 2014, the ECJ ruled on a similar case in the Netherlands that three gay men who had been jailed in countries in Africa and the Middle East should be granted asylum. A Dutch court had said that the men had failed to prove their sexuality.
In the UK, more than two-thirds of the 3,535 asylum applications were based on sexuality in the past two years, according to Home Office data.
Whitehall was criticised in 2017 for implementing a policy to send gay Afghans back to their home country, even though homosexual acts there are illegal and carry a life sentence.
Home Office guidelines state that asylum seekers should "establish [their sexuality] to a reasonable degree of likelihood" and that the declared sexuality should be taken as a starting point in their asylum claim.