There is rightly huge concern and anger in the west at the recent increased homophobia in Africa, in particular Malawi's conviction of a gay couple to 14 years' hard labour, and Uganda's proposed new law for the death penalty. And the campaigning and protests must continue to protect people's rights. But at the same time, it's crucial that there is some understanding of what this is all about if the campaign is to have any chance of making headway.

Anyone who has spent any time in Africa or with Africans will know all too well how toxic this subject has become. There is consensus among the vast majority of Africans that homosexuality is wrong. This is one subject on which a group of Africans from a range of backgrounds and countries will largely agree. In fact, the more articulate opponents of homosexuality are often the most educated, those most exposed to western culture.

In a chaotic, noisy restaurant in Africa a couple of years ago there was an extraordinary conversation, which left me very disturbed. Several very educated professionals – all of whom I liked immensely and saw as decent, honourable people – insisted that homosexuality was un-African, a decadent western problem and would never be tolerated in Africa. Or maybe it would in 50 years' time, was the one concession after several hours of vigorous argument. What's more, they insisted they could never work alongside a gay or lesbian colleague.

The discussion left a deep impression because it was clear that something fundamental about what it means to be African – and it is very hard to generalise about 500 million people – was at stake. I'm not sure I still quite understand, but here are some starting points.

First western reporting misunderstands the role of religion. For example, earlier this week, the BBC carried a report from Uganda in which a pastor in Kampala launched a tirade against homosexuality. But he is not creating that antipathy, he is stewarding it – remember this is one of the most competitive and lucrative career options for upwardly mobile Africans; homophobia becomes a recruiting tool to build their church membership. The increasingly vocal homophobia is largely a phenomenon of rapid and chaotic African urbanisation, a response to tumultuous social and economic change in which traditions of family and village life are being strained to breaking point.

Second, combine that with the historically tense complexity of Africa's relationship with the west: part admiration, part envy, part anger and seething resentment. Anything that smacks of westerners telling Africans what to do prompts instant bridling; it evokes a bitter history of colonialisation and exploitation, which still reaps a terrible legacy of unstable states. The west's history in Africa is riddled with atrocity and outrage for several centuries.

Central to much of that was the emasculation of African men. Warriors were defeated, slaughtered in their thousands by superior technology; they were enslaved and shipped to America; they were disciplined into wage labour in the mines of southern Africa. Traditions of hunting and raiding have been curtailed almost everywhere. Chronic, endemic unemployment defines the majority of African men's lives – farming, on which 80% of the population depends, has always been a woman's job. A crisis of masculinity underlies much of the hysterical rhetoric around homosexuality.

It is the same issue that has inhibited the battle against HIV/Aids. The prejudice against wearing a condom because it is less manly is evident in many African countries; it puts millions of women's lives at risk – as well as men – but despite public information programmes and free condoms it can still prove hard to shift.

There are other issues to consider in the complex background. Sexuality and reproduction have been clearly severed in the west; you have sex and then you make an entirely separate decision to have a child. In most parts of Africa, fertility is intimately bound up with your identity as a woman or man. You are not truly a man until you have fathered a child; and the fathering of children is a key expression of your virility. So the idea of a sexual relationship de-linked from producing children is perceived as "unnatural".

This is a toxic brew and for gay and lesbian rights activists in Africa I see only a long, thankless slog and much personal danger. I very much hope I'm wrong.