At the 1968 Mexico Olympics, US athlete Tommie Smith won the 200m final in a world record time of 19.83 seconds. America's John Carlos came third. Walking to the podium to collect their medals, Smith and Carlos wore black socks and no shoes. They each wore a black glove. As the stadium launched into The Star-Spangled Banner, Smith and Carlos bowed their heads and raised their fists into the night sky. Later Smith said, "We are black, and we are proud of being black. Black America will understand what we did tonight."

Smith and Carlos were banned from the games. The then-president of the IOC, Avery Brundage, thought political statements had no place in sports stadia. (He was president of the American Olympic Committee during the 1936 Munich Games, when athletes raised their hands in the Nazi salute. Brundage had said nothing at the time.)

The argument that politics and sport don't mix is pretty misguided. Discrimination is a human rights issue, and to suggest that human rights are merely political is to fundamentally misunderstand their role in helping the vulnerable and disenfranchised.

In 1968, Brundage was echoing the South African apartheid government's position in 1964. Faced with a ban because they refused to allow black people to compete in the Olympics, white South African politicians accused the sporting community of playing politics. But the IOC was having none of it: brotherhood, dignity and fairness, those laudable sporting values, could not be complicit in flagrant discrimination. South Africa was prohibited from attending the Games until 1992.

It's not just about race. Antonio Rebollo, the paralympic archer, lit the Olympic torch with a flaming arrow in Barcelona in 1992. From time to time the Olympic community has stood up for gender equality too. In 2000, Afghanistan was banned from competing in the games because of the Taliban's brutal discrimination against women. But the IOC's record in this area is somewhat tarnished. Saudi Arabia, Qatar and Brunei have never allowed female athletes to compete in the Olympics; they have faced stern words from the IOC, but they have never been prevented from participating.

There is a profound hypocrisy. With race, gender and disability we have made progress. But, nowhere in the lists of the greatest Olympian moments is there a reference to gay, lesbian and transgender rights. No gay power salute, only ten "out" gay athletes in the Beijing Games and, most shocking of all, no censure of the 84 jurisdictions that criminalise homosexuality.

When people think about countries like Jamaica, Kenya and Ethiopia at the Olympics, they think about the incredible runners, like Usain Bolt. They don't think about what would happen if Bolt were gay. They don't think about the fact that he would face a ten year prison sentence for having consensual sex with an adult man. That being open about his sexual identity would be dangerous, not only because it is illegal but because the levels of homophobic violence in Jamaica are so catastrophically high. In the Maldives and Qatar homosexual acts are punished by whipping. Only ten countries recognise marriage equality.

The Human Dignity Trust has successfully demonstrated through litigation that there is no rational justification for the criminalisation of LGBT identity. Like slavery and apartheid, the criminalisation of consensual same sex sexual conduct is a violation of international law.

Ten years after the Wolfenden report's recommendation in 1957 that homosexual behaviour between consenting adults in private was part of the "realm of private morality which is, in brief and crude terms, not the law's business", the UK decriminalised homosexual acts. Later, in the 1980s, activist lawyers began using human rights principles to challenge the laws criminalising homosexuality. They relied on the core values present in all of the major human rights treaties: the right to dignity, the right to equal treatment, the right not to be tortured or treated in a way that is cruel, inhuman or degrading, the right to privacy and to personal and social development. In Dudgeon v UK (Northern Ireland) (1981), the European court of human rights held that the laws criminalising certain homosexual acts between consenting adult men violated the right to a private life under article 8 of the European Convention.

The UN followed suit Toonen v Australia (1994) when the UN human rights committee found that a Tasmanian statute criminalising sexual acts between consenting adult males, in private, violated the right to privacy enshrined in the international covenant on civil and political rights.

Even when criminal provisions are not enforced, they reduce gay men to the status of 'unapprehended felons', thus entrenching stigma and encouraging discrimination. Fear of discrimination leads to concealment of true identity, and this must be harmful.

Sometimes there is light in the darkness: just a few days ago the new president of Malawi, Joyce Banda, announced that she would overturn Malawi's ban on homosexuality - the first African country to do so since 1994. But mostly the outlook is bleak. Last week it emerged that four Iranian gay men are due to be executed for sodomy under their nation's sharia laws.

In July, London will welcome the Iranian Olympic team.

The Olympics present a unique opportunity to put LGBT rights front and centre. London 2012 will be the world's biggest sporting event, and the city has an opportunity to leave a lasting humanitarian legacy of LGBT rights.

It is entirely appropriate for the Olympics to be the forum for the promotion of LGBT rights. The true Olympic legacy is very different from the one sold to you by the IOC or the London organising committee for the Olympic and Paralympic Games. The games in Ancient Greece were homage to the physical relationships between men and the male body. Writers from Aristophanes to Plato wrote of the homoerotic encounters of beautiful male athletes, while poets and sculptors extolled the perfection of the sportsman's body.

Furthermore, over half the countries that criminalise homosexuality are in the Commonwealth, still living under laws that are the legacy of the British empire. This is curious because, in most of the other European colonial empires, there was no such inheritance from the metropolitan power. In France, for example, criminal laws against homosexuals - so far as they existed under the ancien regime - were swept away by the French Revolution and deleted by Napoleon's codifiers from the criminal codes instituted in France and never exported to its colonial empire. This influenced the laws derived from such codes. Indonesia, for example - formally the Dutch East Indies - is the most populous Islamic country in the world. It has never had criminal laws to punish consensual adult homosexual conduct.

This article ends with three exhortations. The first is to LGBT athletes. You are the only ones who have the glare of attention that can be used to effect real change. If you feel safe to do so, come out and make a visible, memorable, courageous gesture for LGBT rights. Show that you are proud to be LGBT, just as Smith and Carlos were proud to be black.

The second is to the LGBT athletes who don't feel safe - and there must be many of you. I invite you to apply for asylum in this country on the grounds that you will face persecution at home if you are open about your sexual identity. Our supreme court has recognised, in HJ (Iran) in 2010, that a person cannot be asked to conceal their true sexual identity in order to avoid persecution. The court held that people must be allowed to live their lives free from the fear of serious harm coming to them as a result of their sexual identity. No one would consider it acceptable for a straight person to have to hide his or her identity: the same applies to LGBT people. LGBT athletes from the 84 criminalising jurisdictions should use this case to apply for asylum in the UK when they arrive for the Games in July.

Finally, to the IOC Committee. I implore you to ban countries where homosexuality is criminalised from competing in the Olympics. The Games are a valuable way of protecting human rights and promoting equality, a principle enshrined in the Olympic Charter itself. To distinguish between racial apartheid in South Africa, gender apartheid under the Taliban and the criminalisation of consensual sex between adults of the same gender is artificial. Countries that sanction such discrimination, and the violence that goes with it, should not be allowed to compete. Far from bringing politics into sport, this step would fulfil the values of the Olympic Charter.

Mark Stephens is giving a lecture on Tuesday 22 May at the University of East London entitled the Rainbow Legacy: why we must assert the rights of the international LGBT community during the Olympic Games