Pro-China supporters take a selfie with a Chinese national flag during a rally in Hong Kong. (Vincent Yu/AP)

Social media companies increasingly have embraced a role they once shunned, as online police penalizing those crossing certain bright lines: You can lie on their platforms but not be “inauthentic.” You can twist reality but not in a “coordinated” way.

But even these few bright lines came under new pressure Tuesday as China — home to the world’s largest population and the second-largest economy — mounted a rare public defense of what Twitter and Facebook deemed coordinated, inauthentic behavior aimed at manipulating online conversation. A Foreign Ministry spokesman dismissed the allegations, made by the companies a day earlier, that the government had done something wrong in using online resources to portray the protests roiling Hong Kong as the work of “cockroaches” spurred to action by shadowy Western forces.

Rather, ministry spokesman Geng Shuang said, the accounts were not the work of government disinformation teams but Chinese students and others living overseas who “of course have the right to express their point of view.”

The move underscored the awkward and largely uncharted territory the companies have attempted to navigate in the aftermath of the 2016 presidential election in the United States, where Facebook and Twitter faced furious public and political pressure to stem the tide of disinformation on their platforms. Once vehemently opposed to being seen as “arbiters of truth,” both have since built major operations to detect and dismantle forms of online manipulation — even if it means angering important global actors such as the Chinese government.

The emerging global debate over these efforts echoes one in the United States as President Trump and many conservatives say social media companies are acting too aggressively in blocking accounts that they regard as violating their rules for authentic discourse online, portraying such efforts as censorship of political speech. Trump held a White House summit last month highlighting these complaints.

In China, the scale and sophistication of the disinformation effort was not particularly notable, but the decision by the companies to finger a powerful government as responsible — something companies once shied away from — was seen as an indicator of increasing assertiveness by Silicon Valley.

Twitter on Monday shut down nearly 1,000 active accounts that it said were part of the operation and roughly 200,000 it said were created to help the effort. Facebook closed five accounts, seven pages and three groups on its platform it depicted as fake.

Their action generated significant praise among the disinformation research community and politicians who have championed the cause of more transparent online discussion. And the comparative silence of Google, the owner of YouTube and a company with concrete ambitions of working in China, sparked criticism.

The costs for Twitter and Facebook and their long-term plans to rid their platforms of disinformation remained unclear. Facebook at one point was so eager to impress the Chinese, where the platform is mostly blocked to users, that Chief Executive Mark Zuckerberg learned enough Mandarin to give a 20-minute speech in Beijing in 2015.

“It would be a tough call to make for anybody to call out China in an influence operation,” said Ben Nimmo, chief of investigations for Graphika, a network analysis firm based in New York that studies online disinformation.

Facebook and Twitter declined to respond to Geng’s comments Tuesday. Twitter said that it will no longer accept advertising from state-controlled media entities, but that those accounts “will be free to continue to use Twitter to engage in public conversation.” Facebook said it is reviewing its rules for state-owned media.

As U.S.-based companies attempt to manage online discourse globally, there is no international consensus over what qualifies as permissible speech — or permissible tactics in spreading that speech, whether it comes from government operatives or anybody else.

The moves by Facebook and Twitter could set up a major geopolitical clash over how much influence nations can exert on the ways information spreads across the Web.

China has enjoyed virtually unassailable control on social media within its borders, employing systems of strict censorship and surveillance against online topics conflicting with the government's self-asserted ambitions, image and power.

But the social media giants’ response suggests that the country has attempted similar information-manipulation tactics around the world, likely to boost its international support and undermine protests in Hong Kong.

“The Chinese government has built an entire infrastructure to support its efforts at information control, through a combination of censorship and disinformation,” Sen. Mark R. Warner (D-Va.) said in a statement. “And it’s exporting both the technology and ideas information control to authoritarian regimes around the world.”

The fake posts pushed Chinese propaganda efforts and characterized the protesters as terrorists and cockroaches. Some of the profiles were disguised as normal Americans in Nevada, Ohio and Texas; one account, which framed itself as a Trump-supporting “Catholic Defender of the Constitution,” had more than 181,000 followers.

Graham Brookie, director of the Atlantic Council’s Digital Forensic Research Lab, said, “China has undertaken information operations that, much like their foreign policy, have been much more subtle and discreet ... and this is neither subtle nor discreet."

Daniel Sinclair, an independent social media researcher in New York who tracks Chinese influence, says the country’s attempts to steer online debate in the West seem to have grown recently, possibly amid anxieties over how it is being perceived amid a U.S. trade war and the Hong Kong unrest.

“This Chinese nationalism that is spreading across American and Western social media, much of it isn’t true disinformation as we understand it, but a lot of it is backed by actual state propaganda and fake news,” Sinclair said. “I don’t think we’ve ever seen their media machine working at this scale. … With social media, China has new kinds of influence, and new fingers in the Western media, that they haven’t had before.”

Twitter and Facebook are not widely available in China, but they are in Hong Kong. Silicon Valley for years has sought to expand its limited footprint in the world’s most populous nation, with mixed success, as Chinese companies have become major domestic and global players in social media and other areas of advanced technology.

For some researchers, the moves have also cast a harsh spotlight on the lone social media giant that has yet to offer comment: Google, whose YouTube has been similarly criticized for its use in the spread of political misinformation.

Sen. Tom Cotton (R-Ark.) called Twitter’s takedown announcement “a good start,” and he urged Google and its counterparts to end projects with China and “refocus their efforts on researching and tracking disinformation campaigns from hostile state actors.”

Google’s move to phase out an artificial-intelligence contract with the U.S. military, following the company’s past work toward building a search engine that could gain approval from the Chinese government, has drawn rebukes from federal lawmakers. Google has a research partnership with a Beijing university but said its development on the search-engine project has been terminated.

“Two of the three relevant companies have made public statements,” said Alex Stamos, a former security chief at Facebook who now works as an adjunct professor at Stanford University, in tweets late Monday.

For social media companies to attribute attacks to governments, “it’s a lot harder when the actor is financially critical,” he added.

Google did not immediately respond to requests for comment.