BEIJING — Ma Baoli was accustomed to secrets.
By day, he was a police officer in northern China with a wife and a knack for street chases. By night, he led a life as a gay man, furtively running a website for gay people across China at a time when many were viewed as criminals and deviants.
For 16 years, Mr. Ma kept his secret, worried that coming out would mean expulsion from the police force and estrangement from his family. Then in 2012, his superiors at a police department in Qinhuangdao, a coastal city in Hebei Province, uncovered his website and he resigned.
His job lost, his family struggling to accept his sexuality, Mr. Ma set out to turn his passion for connecting gay people into an empire. He created Blued, now China’s most popular gay dating app with an estimated value of $600 million and more than three million active daily users, about as many as Grindr, a popular gay dating app in the United States.
Mr. Ma, 39, said he saw his mission as working to legitimize same-sex relationships at a time when gay people, especially in China, still face discrimination.
“In the past people wouldn’t even talk about homosexuality because they thought it was dirty, it was filthy,” he said. “The internet can help support gay lifestyles, to make people know they are not alone and that their feelings are genuine.”
Mr. Ma also sees a lucrative business opportunity in China’s so-called pink economy, as more people look to spend money on gay-themed social networking sites, entertainment and travel. The spending power of lesbian, gay, bisexual and transgender people in China is estimated at $460 billion per year, making them the largest market in Asia, according to LGBT Capital, an investment management firm.
But translating Mr. Ma’s instincts into an enduring business model has proved challenging. Like many popular technology start-ups in China, Blued is only beginning to make a profit; most of its services, including chat, live-streaming and a news feed, are free. Attracting advertising remains difficult, with some companies reluctant to be associated with a business that caters to gay people.
Mr. Ma has set his sights on foreign markets, hoping to take on established players like Grindr and Hornet. While Blued now dominates in China with more than 80 percent of the gay dating market, analysts said it would probably be difficult for the company to build a large following overseas.
“Culturally, people work differently,” said Paul Thompson, a co-founder of LGBT Capital based in Hong Kong. “It’s much easier to build up this real concentrated drive in one marketplace than it is to do it in lots of places.”
Growing up in northern China as the son of a factory worker and a housewife, Mr. Ma hoped to go to college and become a teacher. But his parents thought his dreams were too costly, and he was sent to the local police academy instead.
It was there, he said, in a macho culture that revolved around talking about women, that he realized he was gay.
At the time, in the mid-1990s, gay sex was considered a crime in China and homosexuality was classified as a psychological disorder. At the police academy, Mr. Ma took courses on criminal psychology where cadets were told that gay people should be viewed suspiciously because they were more likely to commit crimes.
“When I realized I was different from other people,” he recalled, “I thought I was ill.”
Mr. Ma turned to the internet for advice. But instead of finding a supportive community, he found rants describing gay people as lunatics and perverts. On health websites, he was bombarded with recommendations to seek medication and electroshock treatment.
After becoming a police officer, Mr. Ma was inspired in 2000 to start his own website, Danlan.org, Chinese for “light blue,” evoking the clear coastal skies of his childhood. The site offered chat forums and advice on reducing the risk of H.I.V. and other sexually transmitted diseases. Danlan soon became a popular way for gay men in China to connect in an age when many had been resorting to scrawling meeting dates and places on bathroom stalls, worried about the stigma of coming out.
At work, Mr. Ma chased burglars, filed incident reports and recorded public service announcements. In his spare time, he raced to the keyboard, writing essays for Danlan and chatting with friends under the pseudonym Geng Le.
Mr. Ma kept up the routine for more than a decade. He married, under pressure from friends and family. But when his supervisors confronted him about his website in 2012, he offered his resignation. His family was devastated.
“Both of his parents were very traditional, and they thought their kid had a really good job,” said Wu Guoxin, 38, a friend from the police academy. “There was nothing he could do.”
Mr. Ma’s relationship with his wife soon dissolved. His mother was stricken with cancer and Mr. Ma worried that his decision to come out had contributed to her illness. The family agreed to never speak about his sexuality again.
IN his new life as a high-powered technology executive, Mr. Ma still goes by the alias from his Danlan days, Geng Le. In meetings with business partners, he retains the deliberative demeanor of a police officer, nodding his head intently in silence, as if interviewing a witness at a crime scene.
In a sprawling office in central Beijing, where portraits of scantily clad men hang on the wall, Mr. Ma leads a team of about 200 employees. In one corner, workers scan Blued posts for illegal pornography. In another, a team adds Chinese subtitles to a movie that Blued produced in Thailand.
The company is trying to increase its revenue by expanding into gay travel and entertainment.
Mr. Ma also hopes to bring more advertising to the app, and he sees potential for growth in live-streaming features, a wildly popular form of communication in China. Blued has more than 200,000 hosts who broadcast around the clock on a variety of topics — music, dating, fitness and cooking. Some earn up to $15,000 a month in tips paid by users, the company says, with Blued taking a share of each payment.
As he works to build his business, Mr. Ma said he was also looking for ways to improve the lives of gay people in China. Blued offers free H.I.V. testing at clinics in Beijing, and the company has helped pay to fly same-sex couples to the United States to be married.
Mr. Ma said he was optimistic that long-entrenched stereotypes were fading in China and that within two decades, the country would embrace ideas like same-sex marriage.
He quoted his idol, the Alibaba.com founder Jack Ma, in describing both the challenge of building a successful start-up in China and the struggles of the gay-rights movement.
“When I’m at my most painful moments,” he said, “I remember what Jack Ma said: ‘Today is hard, tomorrow will be worse, but the day after tomorrow will be sunshine.’ ”