Open this photo in gallery People wearing face masks cross a road by the Yangtze river after lockdown in Wuhan, the epicentre of China's novel coronavirus disease outbreak, is lifted on April 8, 2020. ALY SONG/Reuters

As the hikers make their way down an orchard path on the outskirts of Beijing, villagers block the road ahead of them. One bends down to pick up a stone.

“We are afraid of being infected. We are scared you have some disease,” one villager calls out to the hikers, a small group of people from Europe, the United States, India and China out for a weekend nature walk. “Stay away from here,” the villager says in cellphone video seen by The Globe and Mail.

The emergence of a deadly virus from China has created a worldwide wave of discrimination, sometimes violent, against people of Asian descent over the past few months.

Story continues below advertisement

But now that the Chinese government has declared the virus under control at home, foreign residents in China have become victims of discrimination.

“It’s palpable. People get out of the elevators sometimes in my building when I get in,” said Trevor Metz, a restaurateur in Beijing who is also the host of Not a Team Player, a podcast about life in the Chinese capital. On Thursday, he was at a mala xiang guo restaurant with a friend when a man in a back corner loudly berated a server: “Why are you letting foreigners in here? You shouldn’t let foreigners in here.” The man then stormed out.

The server, Mr. Metz added, “treated us very well.”

But similar scenes are playing out across Beijing and the rest of China. One Mexican restaurant popular with expatriates posted a sign saying foreigners could no longer enter. Entire alleyways have blocked non-Chinese people from entering. Fitness facilities have done the same. A repair person told a Globe reporter that he would not do home service calls for foreign residents.

In the southern city of Guangzhou, which has a large Nigerian community, roughly 100 people are now living on the streets after hotels refused to take more foreigners in the Sanyuanli area, which is so popular with foreign traders that it’s been dubbed “Little Africa.” With nighttime temperatures dipping into the teens, the local community has begun donating food and blankets to those staying outside.

“Sometimes the hotels are not allowing them in because the hotels believe there are too many foreigners already in that hotel,” said Maximus Ogbonna, president of the Nigerian community in Guangzhou. He has gone out to speak with those now living on the streets. With flights cancelled between China and Nigeria, many feel stuck. Plans are under way to send an evacuation plane.

At the same time, authorities are also demanding virus tests of all foreigners, said Mr. Ogbonna, who was himself tested. He didn’t complain. “It’s for people’s good, to make sure everyone is virus-free,” he said. And “they are not charging for the test.”

Story continues below advertisement

But local authorities have also required Africans to quarantine for 14 days, even if they have not been abroad for many months. The policy, enforced by police, is forcing people into a sort of medical prison by virtue of their passports.

“Any person who has not been quarantined before, that person must go into quarantine now,” Mr. Ogbonna said. He understands why. Chinese authorities “feel they have solved their own problem” domestically by containing the virus, “The cases they have now are imported cases from other countries. That’s why they want to test all the foreigners.”

Other members of the Nigerian business community, however, are furious. “The virus came from China,” said Jude Izuchukwu Udeji, a Nigerian electronics importer. Nigeria, the world’s seventh-most populous country, has reported just 276 cases of COVID-19. And yet “in China, some of our people are being treated like animals,” Mr. Udeji said. “And I don’t know why they are doing this to us."

China now counts 983 cases that it calls “imported,” meaning people who have brought the virus into the country from elsewhere. But the Foreign Ministry has said that some 90 per cent of such cases are Chinese citizens coming home from abroad.

Suspicion of foreigners is far from universal. In chat groups and conversations, expatriates in China have described gifts of flowers and other displays of generosity by locals, including care for those in quarantine.

Chinese authorities, who angrily denounced virus-based discrimination against Chinese people overseas, have denied the existence of similar treatment of foreign residents in China.

Story continues below advertisement

“There have been cases of Asians or Chinese being attacked or verbally abused in some countries. But there have been no cases of foreigners being maltreated in such a way on the Chinese mainland,” China Daily wrote in an editorial Wednesday. “We treat all foreign nationals equally in China,” Foreign Ministry spokesman Zhao Lijian said Thursday.

But China has banned the entry of virtually all foreigners – even those with residence permits – and suggested that diplomats, too, refrain from flying into the country.

Chinese media have also directed attention at foreigners, with state propaganda organs this week deriding a group of non-Chinese students who picnicked at a park without wearing masks.

A comic that circulated broadly on social media, meanwhile, showed foreigners – one dark-skinned, one blond – being tossed into garbage bins under the heading “sorting foreign trash.”

Sign up for the Coronavirus Update newsletter to read the day’s essential coronavirus news, features and explainers written by Globe.