BEIJING — After Houston Rockets General Manager Daryl Morey tweeted support for Hong Kong’s pro-democracy protesters on Friday, the National Basketball Association franchise found itself engulfed in a backlash from seething Chinese fans and faced cries for a boycott.

Forty-eight hours later, China’s state broadcaster said it would not show games of what had been one of China’s most beloved sports teams. Corporate sponsors peeled away. The Chinese Basketball Association — headed by former Rockets star Yao Ming — also cut ties.

Practically overnight, the Rockets were grounded by an increasingly powerful force in global business: Chinese nationalism.

As China’s economic clout expands, its government and consumers are coercing international companies and punishing speech they deem critical, adding a growing element of unpredictability for foreign executives weighing the opportunities and risks of doing business in the country.

With the politically charged trade war with the United States grinding on and the Chinese economy cooling off, the latest NBA controversy was a reminder that many foreign executives say the country of 400 million middle-class consumers is more a minefield than a gold mine.

“The political risk is so high right now it doesn’t make sense to keep investing in China. If you’re not already here, you have to think three, four, five times harder about whether it’s worth coming,” said Shaun Rein, the Shanghai-based founder of the China Market Research Group who has advised clients such as Apple, Samsung, Fidelity Investments and luxury group Richemont.

Rein, an author known in China for his pro-Beijing views and support for hard-line President Xi Jinping, said the political atmosphere had become so charged that even he is advising companies to leave. “It’s killing my business, frankly,” he said, “but you can’t put all your eggs in this basket anymore.”

Joerg Wuttke, president of the European Chamber of Commerce in Beijing, said the boycott against the Rockets was a familiar pressure tactic. “It is unfortunately a part of the Chinese toolbox to hold foreign companies hostage,” he said.

Yet unlike previous boycotts motivated by geopolitical tensions, the outpouring of anger toward the Rockets over the weekend appeared to be organic in a country where many Chinese, some of whom are guided by a steady stream of state propaganda, see the Hong Kong protests as something far different from how Western publics do: as a violent movement orchestrated by the United States to cleave away Chinese territory.

So when Morey retweeted an image with the words “Fight for Freedom. Stand with Hong Kong” on Friday night, days before the NBA was scheduled to hold preseason games in China, Chinese social media exploded.

Many users compared Morey’s remarks to former Los Angeles Clippers owner Donald Sterling using racist language and demanded that the league remove Morey like it did Sterling.

The league, Rockets owner Tilman Fertitta and Morey quickly apologized, but that didn’t stop the Chinese sportswear brand Li-Ning, a major Shanghai bank and an electronics maker from suspending ties with the team. Brooklyn Nets co-owner Joe Tsai criticized Morey as “not being as well-informed as he should’ve been,” and Tsai’s company, the Chinese e-commerce giant Alibaba, removed Rockets items from its vast online platform.

Meanwhile, the influential state broadcaster, CCTV, demanded that Morey apologize and warned: “Double-faced behavior attempting to make money from China while hurting the feelings of Chinese people will not work and is doomed to pay a price!”

But in Washington, lawmakers from both parties, including Sens. Charles E. Schumer (D-N.Y.), Ted Cruz (R-Tex.) and Marco Rubio (R-Fla.) immediately backed Morey’s right to free speech and criticized what they called “unacceptable” Chinese efforts to silence him.

The dispute over the NBA, of all things, may “crystallize to many more people the ability of the PRC and the allure of its market to bring even the most powerful and popular American institutions to heel,” said Bill Bishop, the Washington-based publisher of the Sinocism newsletter, referring to the People’s Republic of China.

For the Rockets and the NBA, China had been a qualified success story. After former commissioner David Stern began mailing videotapes of NBA games to Chinese state television in 1987, the NBA steadily grew to become the country’s most popular sports league — an ascent boosted when the Rockets picked a towering center from Shanghai, Yao Ming, in the 2002 draft.

Today, some 500 million people in China watch the NBA, and the Internet giant Tencent in July signed a reported five-year, $1.5 billion deal to stream league games. Rockets superstar guard James Harden is a household name who appears in China regularly to sell shoes and run youth camps.

Mark Dreyer, the editor of China Sports Insider, predicted that the furor may soon die down because the NBA apologized quickly, and because Chinese nationalist outrage seems to cycle through targets.

In 2017, a Chinese government-led boycott crippled the South Korean retail conglomerate Lotte after the company allowed a U.S. missile defense system to be installed on its land. In the years since, threats of boycotts seemed to surface on a regular basis.

Mercedes-Benz was labeled an “enemy of the people” following an Instagram post quoting the Dalai Lama, whom many Chinese consider a separatist. Marriott sparked outrage because it listed Taiwan as a country, when many Chinese consider it a territory of the People’s Republic. Leica, the camera maker, had to apologize for celebrating the legacy of photojournalists who covered the Tiananmen crisis, a taboo subject.

Rein, the Shanghai-based consultant, said the cycles of nationalist outrage are putting off businesses precisely at a time when the Chinese government is courting them to stay by lowering restrictions on investments.

Chinese officials say foreign investment into the country has held steady even though a survey last month by the American Chamber of Commerce in Shanghai showed sentiment souring sharply.

Jonathan Sullivan, director of China programs at the University of Nottingham, said the impact of the Rockets controversy will be far-reaching.

“Going forward, every foreign company doing business in China will reinforce the message to their employees that a representative of a company will not be able to voice an opinion that does not accord with China’s own interpretation of the facts,” he said.