Bernard Randall, the British gay man charged with homosexuality-related offences in a Ugandan court, glances up sceptically when I walk into his lawyer's chambers. His Ugandan partner, Albert Cheptoyek, sits protectively in front of him, closer to the door, on a rickety wooden bench. Cheptoyek's white shirt illuminates his dark sweaty skin, while Randall's oversize dull-coloured clothes match his face, making him almost invisible.

And that perhaps may just be the effect he needs to get through the ordeal of having the content of a sex tape of him and his 30-year-old partner splashed over newspapers and across the media here. And not just any media, but the media of a country that has declared homosexuality to be an evil practice, a cancer imported from the west that must be stamped out no matter what the cost.

In 2009, Ugandan MPs proposed the death penalty for certain homosexual acts. The anti-homosexuality bill was shelved after international pressure, but it remains on parliament's order paper and could be debated and passed at any time.

In Uganda the media routinely out gay people in an attempt to "protect" the moral fabric of society. In 2010 a tabloid called the Rolling Stone printed the names and addresses of people perceived to be gay and called on the public to hang them.

Randall, 65, says that he became a victim of such an outing after his computer was stolen, a video of him and his partner leaked and pictures from it published in a tabloid. He faces the possibility of two years in prison. His partner faces the more serious charge of carrying out acts of gross indecency that carries a seven-year prison sentence.

The charges are visibly weighing down on them. Randall's eyes, fatigued and bloodshot, have big bags under them. He involuntarily sits on the edge of the seat, as far from me as possible, protecting himself subtly with his arms. He seems to age before my eyes.

Certainly it is easy to see that Cheptoyek, perhaps more familiar with Uganda's anti-homosexuality outbursts, is his protector. He declares there will be no interview, even though I have an appointment.

"How do I know you are who you say you are? How do I know that you are not from NTV?" he says, referring to one of the TV stations that he feels covered their story unfairly.

Their eyes are pleading. Cheptoyek asks me firmly to leave them alone. And then out of nowhere, almost weeping, he says: "We have been through so much. Those people put my photos all over the place. We do not know what to do."

They are lost. Life after this ordeal will be almost impossible. They know that the Ugandan public, an estimated 90% of whom support the anti-homosexuality bill, will not welcome them back. Like other outed Ugandans before them, they risk threats, evictions, even death. As a result, Cheptoyek and Randall will trust only foreign journalists. Their only hope lies in the west after the country they call home – in Randall's case, chose to call home – has become hostile beyond their imagination.

Uganda has been called the worst nation in which to be gay. It was its anti-homosexuality bill that first brought its homophobic attitudes to the attention of the world, attracting powerful criticism from Europe and America, where it was dubbed barbaric and a violation of fundamental human rights. Britain and the US both threatened to cut aid to Uganda if it passed the bill. Uganda interpreted this reaction as evidence that the west was imposing a "gay agenda" on Africa.

Yoweri Museveni, Uganda's president for the last 27 years, described homosexuality as a decadent culture from the west and a threat to African values and Christianity. He showed open support for the bill but later backed down in the face of widespread international pressure. However, his ministers have continued to preach anti-gay rhetoric, urging gays to leave the country.

But Frank Mugisha, executive director of Sexual Minorities Uganda, thinks that the accusation that the west is promoting homosexuality is misguided. "People are exaggerating the influence of foreigners in the gay rights campaign in Uganda. The same people who fund other activities fund gay rights organisations. We do not have special donors," he says. "When we started our campaigns in 2007, we did not have any foreign funders. It was a naive gamble rather than a foreign-aided campaign."

In fact, the greatest foreign influence in the gay rights debate in Uganda comes from the western evangelical movement that is spreading radical ideas rejected in their own countries, Mugisha says. His organisation is suing evangelist Scott Lively in a US court for his involvement in what Mugisha calls persecution of gays and abuse of their fundamental rights.

Homosexuality is a common theme in churches in Uganda, with religious leaders castigating gay people at every opportunity. The country has held national prayers against homosexuality. In 2010 a pastor, Martin Ssempa, showed videos in his church of gay people having sex in a bid to convince his congregation of the dangers and to try to trigger disgust about gays.

Funded by evangelical movements from America, anti-gay churches have linked the high prevalence of HIV and Aids in the country to homosexuality. They have accused homosexuals of going to school and "recruiting" underage children.

Mugisha says evangelists have played on the psyche of many Ugandans. "They come here with their own agenda. It is like colonialism."

But to the ordinary Ugandan the Randall trial is yet more proof that there are foreigners who come to Uganda with one mission – to spread homosexuality. Mugisha argues that the socio-legal regime that sanctions homophobia and the idea that homosexuality is foreign has made foreigners an easy target for extortionists.

"We have seen this before. Many people blackmail white men and even rich black people known to be gay. Randall is unfortunate that his story reached the public."

Frederick Juuko, a Ugandan law professor and critic of foreign influence in Ugandan politics, agrees that homosexuality is a pawn for many in times of desperation, including government. He says Uganda is a failed state and that blaming foreigners for homosexuality is a handy distraction.

My encounter with Randall and Cheptoyek comes to a rapid end; it is soon time for them to make their daily trip to the police station – a condition of their bail.

"We have to go and deal with this," Cheptoyek says. They drive off, stopping after a few metres to let a guard slither into the back seat, just in case.