One of the most striking images of last month was a White House lit up in rainbow colours to mark the US supreme court’s historic ruling on the legalisation of same-sex marriage; 26 million Facebook users joined the celebration by overlaying their profile picture with a rainbow filter. It was a momentous victory for the movement for same-sex marriage, now legal in 20 countries around the world.

The positive shift in social attitudes towards homosexuality across much of North America, western Europe and Latin America in the past two decades has been remarkable, all the more so in light of the fact that just 60 years ago, homosexuality was almost universally illegal.

But last week’s warnings to President Obama not to use his visit to Kenya this month to raise the issue of gay rights serve as a chilling reminder that, globally, the war for LGBTI rights is being fought on two fronts. There is the fight for gay equality in Europe and America, which has had much to celebrate. But across much of the Middle East, Africa and Russia, the fight takes a crueller form: for the right not to suffer criminal punishment for exercising the right to love whomever one wishes.

Across most of Africa, same-sex relationships remain illegal and public attitudes towards homosexuality are the most negative in the world. A wave of populist leaders in countries such as Uganda and Nigeria has sought to make political capital by championing laws strengthening the criminalisation of homosexuality.

In the Middle East, Isis has released shocking photos of executions of gay men, pushed to their deaths from tall buildings in front of crowds of people. Even in Turkey, one of the few countries in the region where homosexuality is legal, there were backlashes against activists by Turkish police at Istanbul’s annual gay pride parade. Russia has seen an increase in LGBTI violence in the wake of the signing into law of a bill that bans homosexual “propaganda” in 2013. And in India, the supreme court reinstated a law banning gay sex at end of 2013.

These cases show how even as gay rights have been advanced in the west, many regions of the world are moving backwards. Celebrating success on one front should not mean taking the eye off the other. Western leaders such as Barack Obama and David Cameron, who have done much to champion gay equality domestically, must play a role in advancing the cause of gay rights internationally.

But the Ugandan example shows how poorly handled interventions can have unintended consequences. In 2011, Mr Cameron threatened Uganda with cuts to international aid as a result of political support for a law to recriminalise homosexuality. Since the law was passed in 2014, many western nations, including the US and the Netherlands, have indeed cut aid to Uganda. Many African gay rights activists have criticised such cuts as playing into the hands of leaders who have used an anti-gay agenda to build popular support, allowing them to hold LGBTI groups up as scapegoats. It has enabled politicians to make the debate one of national sovereignty in the face of western imperialism. While Uganda’s supreme court has since overturned the law on a technicality, the government is planning on introducing another, more draconian law.

Of course western governments should publicly condemn the flouting of basic human rights. But withholding aid can be dangerously counter-productive and risks charges of hypocrisy when different approaches are taken with different countries. Saudi Arabia takes one of the harshest approaches to homosexuality in the world, but there is no suggestion that this has had any impact on its relations with the US, for instance.

This must be seen as an agenda led by African activists, championing African, not western, liberal values

No one would advocate this strategy for gender rights. Far from cutting aid to countries that discriminate against women, money has gone into education for girls and supporting local advocates for gender equality. Why is this approach then not being deployed to advance global LGBTI rights?

The truth is western governments have been reluctant to invest in local gay rights advocacy and community-led programmes aimed at fostering dialogue and tolerance. If we are serious about promoting international gay rights, this must change. This must be seen as an agenda led by African activists, championing African, not western, liberal values. Public condemnation – while relatively easy– will, by itself, achieve little.