HONG KONG — After 16 years in China, a Congolese businessman thought he knew what being black there entailed. He had been subjected to racial slurs and denied apartments, but he had also learned Chinese and made local friends. He loved the country; he called it his second home.
But the businessman, Felly Mwamba, had not anticipated the coronavirus pandemic, during which he would find himself sealed in his home, prohibited from leaving and eyed as a carrier of the disease, simply because he was African.
“The way they are treating black people, you cannot accept,” Mr. Mwamba said by telephone. “We are not animals.”
As China tames the coronavirus epidemic now ravaging other countries, its success is giving rise to an increasingly strident blend of patriotism, nationalism and xenophobia, at a pitch many say has not been seen in decades.
A restaurant in northern China put up a banner celebrating the virus’s spread in the United States. A widely circulated cartoon showed foreigners being sorted into trash bins. African residents in the southern city of Guangzhou, including Mr. Mwamba, have been corralled into forced quarantines, labeled as dangers to the country’s health.
Some of the uglier manifestations of nationalism have been fueled by government propaganda, which has touted China’s response to the virus as evidence of the ruling Communist Party’s superiority. And recriminations from abroad, including calls to make China pay for the pandemic that began there, have triggered defensiveness on the part of many Chinese.
Whipping up national pride has long been a tool for solidifying the party’s grip on power. In the short term, the nationalism may be useful to the central government, as it seeks to quell lingering discontent over its early attempts to play down the outbreak.
But if left unchecked, the vitriol risks isolating China internationally, just as the Communist Party seeks to use the pandemic to promote itself as a global leader. In recent days, countries that are usually friendly with China have denounced Chinese xenophobia, while business leaders have warned of difficulties operating there.
“The real risk that the nationalism poses is to foreign governments’ perception of threat from China,” said Jessica Chen Weiss, a professor at Cornell University who has studied Chinese nationalism.
China’s heightened us-against-them mentality is perhaps most apparent in its recent strictures aimed at foreigners. Though the Chinese government denounced racist attacks against Asians overseas when the outbreak was centered in China, it now casts people from other countries as public health risks.
Last month, China barred virtually all foreigners from entering, even though it had criticized other countries for closing their borders. Officials emphasize that most of China’s new cases are now imported — often without mentioning that many are Chinese nationals returning home.
Fear of imported infections has at times exploded into, or provided cover for, xenophobia.
In Beijing and Shanghai, foreigners have been barred from some shops and gyms, supposedly as part of a campaign to combat the virus. “We are temporarily not accepting foreign friends and people whose temperature is above 37.3,” read a sign in a hair salon near Beijing’s central business district.
A salon employee said she didn’t see it as discrimination. “It is an epidemic, after all,” she said.
John Artman, the American editor of a Chinese tech publication, said his office building in Beijing reopened last month after closing during the outbreak. But he was told that the building was not admitting foreigners.
By coincidence, the company was already planning to move its office. But when he tried to visit the new office two weeks later, a colleague said the new site, too, would not permit foreigners to enter. Mr. Artman is still working from home.
In Yiwu, a city in Zhejiang Province, Lucky Destiny, a Nigerian jewelry exporter, said that whenever he went outside during the past two weeks, locals would cover their noses or move away. Shopkeepers shooed him away, and people got off buses when he boarded.
He has taken to buying food only at night, when the streets are emptier.
“I had a plan for business, being able to build something for my family,” said Mr. Destiny, 28. “If this continues, I will try to leave.”
The authorities have said their outbreak prevention measures apply equally to Chinese and non-Chinese. But they have sometimes singled out foreigners in the same breath. A recent editorial in China Daily, a state-run newspaper, denied discrimination against foreigners, even as it said that “some foreigners choose to flout China’s rules” on containment.
Some expressions of antiforeigner sentiment have made no pretense about public health concerns. Last month, a porridge restaurant in the northeastern city of Shenyang displayed a banner that read: “Celebrating the epidemic in the United States and wishing coronavirus a nice trip to Japan.”
Perhaps nowhere has xenophobia manifested itself more strongly than in Guangzhou, a manufacturing hub with a large African population.
In recent days, African residents have reported being evicted from their homes and hotels, after five Nigerians there tested positive for the virus. Africans have also been ordered to undergo 14-day quarantines at their own expense, even if they have no recent travel history or have already tested negative.
Images shared on social media showed groups of black people sleeping on a sidewalk, and a sign banning black people from a McDonald’s.
Mr. Mwamba, the Congolese trader, said he and other community leaders spent one night last week walking around the city, looking for lodging for Congolese students who had been ejected from their hotel. Soon after, his apartment door was taped shut with Mr. Mwamba inside, and local officials told him he could not go out for 14 days, he said.
The events in Guangzhou have drawn sharp — and unusual — condemnation from officials in Africa, where China has cultivated close ties and economic reliance through billions of dollars in loans and investments.
Ghana’s foreign minister on Saturday criticized the “inhumane treatment” of Africans in China. A group of African ambassadors wrote a letter to China’s foreign minister denouncing “stigmatization and discrimination.”
Foreigners are not the only targets of China’s swelling nationalism. Chinese people deemed insufficiently admiring of the government have been subjected to vitriolic online attacks by China’s army of “little pinks,” a nickname for the generation of young digital warriors who pounce on any criticism of the Communist Party.
They recently targeted a novelist, Fang Fang, who for two months published a daily journal of life under lockdown in Wuhan, where the outbreak began. She wrote of the bravery of ordinary people around her, while also vowing to hold local government officials to account.
When news emerged last week that her diary would be translated and published in English, she faced a torrent of abuse, accusing her of helping foreign governments undermine her own country.
“Her writings are being used to blackmail China, to demand that China pay compensation, to bring China to trial, to interrogate China,” Sima Nan, a Maoist scholar and well-known defender of Communist Party rule, said about Fang Fang in an interview. “She has become a political tool.”
Fang Fang has likened the harassment to her childhood during the Cultural Revolution of the 1960s and ’70s, when anyone seen as even mildly critical of Mao Zedong risked torture or imprisonment.
A few prominent voices have warned of the dangers of excessive national pride. In a recent essay, Hua Sheng, a respected economist, urged more introspection.
“Some people say if we investigate our country’s culpability, we would be giving evidence to outsiders and giving them a sword with which to hurt our national interests,” he wrote. “I must say, it’s precisely the opposite.”
There are signs that the nationalism already threatens to create a backlash that could undermine China’s economic and diplomatic status.
Jörg Wuttke, president of the European Union Chamber of Commerce in China, said in an interview that the scope of limitations on foreigners in China was “much deeper” than in other countries and “excludes us from a lot of public spaces.” The chamber has called China’s restrictions on arriving foreigners an “unprecedented challenge” for corporations.
Further hostility could intensify existing pressure for countries to reduce their reliance on China. Last week, Japan — historically a target of Chinese nationalism — announced a $2.2 billion fund to help companies shift production out of China.
The next day, Larry Kudlow, a top economic adviser to President Trump, suggested that the United States follow suit and “pay the moving costs of American companies from China back to the U.S.”
Mr. Mwamba, who exports motorcycle parts and construction materials, has been contemplating a move of his own, despite his deep ties to the country.
“This week made me really think a lot,” he said. “I love China, but sometimes, I’m feeling tired.”
Vivian Wang reported from Hong Kong and Amy Qin from Taipei, Taiwan. Keith Bradsher contributed reporting from Beijing.