MA BAOLI had served in the police force of the coastal city of Qinhuangdao for 16 years when, in 2012, his superiors delivered an ultimatum. During his spare time Mr Ma (pictured), who is now 37, had secretly been running a website for gay men, Danlan.org, which had begun to attract the attention of the local press. Outed, he was told he could either shut his site or hand over his badge. “They considered it a sensitive issue…that a policeman was gay,” Mr Ma says. “So I thought, I’ll just quit.”

Later that year Mr Ma set up a company, Blue City. It launched a male gay-dating app called Blued that helps locate potential partners using global-positioning technology. The app now has a staff of 60 and around 15m users, making it one of the most popular of its kind in the world. In November Blue City got $30m in funding from DCM Ventures, an American venture-capital firm. Mr Ma plans to expand his app’s user base to 20m-25m by the end of this year and to launch a sister one for lesbians, Pinkd.

It was very different in the 1990s when, as a young man, Mr Ma risked being sent to a labour camp for “hooliganism”, the crime then attached to homosexual behaviour, by scrawling “I’m gay” on public-lavatory walls in the hope of meeting partners. Homosexuality was not decriminalised until 1997. Now the government is far more tolerant. In 2012 Li Keqiang, who was then a deputy prime-minister (he is now prime minister), met Mr Ma and praised his efforts to help to raise awareness of HIV/AIDS. In late January a court in the southern city of Shenzhen became the first in the country to hear a case involving alleged discrimination against a gay man (who says he was fired for being homosexual). A verdict is expected in a few weeks.

As Blued’s user-base grows, Mr Ma plans to add features such as an e-commerce function. He also wants to break into new markets. In February Blue City is due to launch an English-language version of Blued. It will be aimed at gay men worldwide.