BEIJING — With hashtags like #Iamgaynotapervert and images of hearts and rainbows, tens of thousands of Chinese residents took to social media over the weekend to protest efforts to censor gay-themed images, videos and cartoons.

The uproar was in response to a vow on Friday by Sina Weibo, one of China’s most popular social media sites, to delete posts relating to gay culture, part of a three-month “cleanup” effort.

Sina Weibo, a site similar to Twitter, said in its announcement that it was trying to limit the spread of sexually suggestive and violent content and that it would target cartoons, pictures, texts, short videos and romantic fiction. The site said its aim was to promote a “clear and harmonious” environment and to comply with stricter cybersecurity laws put in place by President Xi Jinping.

But many users were incensed, saying the campaign was another sign of discrimination against lesbian, gay, bisexual and transgender people in China, more than two decades after the country decriminalized homosexuality.