Where is it illegal to be gay?
Millions of people continue to live in places that outlaw same-sex relationships and prosecute people for being gay. In five countries and in parts of two others, homosexuality is still punishable with the death penalty, while a further 70 imprison citizens because of their sexual orientation.
Even where homosexuality is legal, many countries treat those in same-sex relationships differently, such as having an unequal age of consent or a ban on marriage. In Russia, host of the Sochi Winter Olympics, a law banning the promotion of "non-traditional" sexuality to under-18s was introduced last year.
So, where is it illegal to be gay? Which countries allow same-sex marriages? Explore the map of UN member states below to find out. Countries are coloured and categorised by their most anti-gay or pro-equality laws.
Notes on the data: The map shows an overview of the legal status of gay people living in UN member states. They are coloured by their most anti-gay or pro-equality laws on a scale of red to blue. Where a country falls into two contradictory categories this is reflected in the key. Where countries have varied laws, this is noted in the rollover text when available on your device. The map and key show legal status only and do not reflect day-to-day experiences. In many places where anti-discrimination laws exist, gay people continue to be persecuted by state authorities and wider society. Read the full notes.
Decriminalising being gay
During the last 200 years, an increasing number of countries have decriminalised same-sex relationships. After a period of criminalisation before the French Revolution in 1789, the trend towards decriminalisation gathered pace - particularly in the 1960s and 1970s.
However, some countries are moving in the opposite direction, introducing punitive new laws and strengthening existing penalties. Last year, India reinstated a 153-year-old colonial-era law criminalising gay sex. Nigeria, which already bans gay relationships, also recently outlawed same-sex marriages, gay groups and shows of same-sex public affection.
Olympic host Russia also introduced controversial legislation in June that prescribes fines for anyone giving information about homosexuality to people under 18.
Legal status of homosexuality: 1789-2014
In 1789, the timeline's starting point, homosexuality was illegal in 126 countries.
*with the exception of the Chechen Republic.
Note: Where possible, former colonies have been referenced by their current name.
Produced by Lucy Rodgers, Pablo Gutierrez Martin, Martyn Rees and Steven Connor