Supreme court judges predicted that "more and more" gay and lesbian refugees are likely to seek protection in Britain after a landmark legal ruling recognised the rights of asylum seekers.

Five supreme court justices said gay and lesbian asylum seekers should not be expected to "exercise discretion" in their home countries to avoid persecution. Their ruling met with cheers and applause from campaigners.

But the Home Office moved to dampen claims from anti-immigration groups that the ruling could lead to a massive expansion of asylum claims from "millions of people around the world".

Lord Hope, one of the judges, said that for many years some countries had simply insisted homosexuality did not exist, which avoided the evil of persecution.

However, anti-gay sentiment had dramatically worsened in some places, fanned by "the rampant homophobic teaching that right-wing evangelical Christian churches indulge in throughout much of sub-Saharan Africa" and "the ultra-conservative interpretation of Islamic law that prevails in Iran".

The gulf was set grow, he said. "More and more gays and lesbians are likely to have to seek protection here as protection is being denied to them by the state in their home countries." They cited parallel British examples of being free to enjoy going to a Kylie concert, cocktails, or talking about men to female friends.

The home secretary, Theresa May, said the ruling was a vindication of the coalition government's decision to halt the deportation of asylum seekers whose sexual orientation had put them at proven risk of imprisonment, torture or execution.

"I do not believe it is acceptable to send people home and expect them to hide their sexuality to avoid persecution," said May. "Asylum decisions will be considered under the new rules."

The Liberal Democrat deputy leader, Simon Hughes, said he hoped the ruling would go some way to restoring Britain's reputation as a human rights haven. He appealed to other countries to follow.

Stonewall, the lesbian, gay and bisexual charity, said there were 80 UN member countries where consensual homosexual sex was still illegal, including six that imposed the death penalty. Uganda is deciding whether or not to become the seventh.

But Sir Andrew Green, chairman of the campaign group Migrationwatch, said the ruling "could apply to millions of people around the world".

He added: "An applicant has now only to show that he or she is homosexual and intends to return and live openly in one of the many countries where it is illegal, to be granted asylum in the UK." The Home Office said this was unlikely, as each individual had to prove they faced a personal threat of persecution or imprisonment.

The applicants whose case was decided by the supreme court, an Iranian known as "HJ", 40, and a Cameroonian, "HT", 36, have had their claims referred back to tribunals. They were refused asylum on the grounds that they could avoid persecution by exercising "discretion" in their countries, despite the possibility of being beheaded in Iran, and an attack on HT in Cameroon in which a crowd beat him and attempted to cut off his penis with a knife.

The men challenged the law after a previous court of appeal ruling stated that asylum could be refused depending on "whether discretion was something that the applicant could reasonably be expected to tolerate".

Abbey Kiwanuka, 29, from Uganda, said: "This gives me hope for my appeal. I feared for my life in Uganda. Just two weeks ago a gay man was beheaded. I lost my appeal because the court said I should go back and live a discreet life. I can't do that. It's impossible to do."