BEIJING – First, videos of rude foreigners went viral in Chinese cyberspace, then a Beijing police crackdown on visitors without valid visas drew fervent applause, and finally, a state TV host urged his countrymen to toss out the "foreign trash."
The latest anti-foreigner stirring in China has put the spotlight on outsiders at a time when its leaders would welcome any distraction from the slowing economy, a high-level political scandal and a blind activist's daring flight into U.S. custody.
The government also has exchanged bellicose rhetoric with the Philippines in a standoff over remote islands while state-run newspapers have attacked the American ambassador over the U.S. involvement in the case of activist Chen Guangcheng.
China's leaders and official media frequently blame foreigners for domestic woes, tapping into a nationalism fed by steady reminders of affronts at the hands of foreigners over the past two centuries.
As the country prepares for a once-a-decade leadership transition this year — already marred by the downfall of a top leader amid a murder investigation against his wife — the government is more sensitive than ever about foreign interference.
"This is an unsettled time in China because of the political transition," said James McGregor, a senior counselor for consulting firm APCO Worldwide.
"So, I think they genuinely worry about foreigners agitating because they always turn to 'It must be the foreigners' fault' when things go wrong," said McGregor, also a former chairman of the American Chamber of Commerce in China.
Earlier this month, an amateur video con China's Twitter-like sites showed a British man allegedly sexually assaulting a Chinese woman near a Beijing mall and then being beaten up by Chinese men.
State TV broadcast the video for several days, and police said the man was apprehended.
Later, Beijing authorities announced a three-month crackdown on foreigners without valid visas or work documents, illustrating its campaign with a graphic of a clenched fist. Microbloggers called the move overdue and urged police to round up foreign drug dealers.
Into this waded TV personality Yang Rui, host of an English-language talk show on state CCTV, who ranted on a microblog last week that the police should arrest the "foreign hoodlums and protect innocent girls."
Yang railed against the "unemployed people from America and Europe who come to China to take our money, traffic in humans and spread heresy to encourage emigration."
He exhorted the authorities to: "Identify the foreign spies who look for Chinese women to live with and whose occupation is to collect intelligence and compile maps and GPS data for Japan, Korea and the West while pretending to be tourists."
Many observers noted that, while Beijing authorities have every right to crack down on the many foreigners living or working without proper documents, Yang's comments smacked of racism and unnecessarily stoked anti-foreign sentiment online.
"It did sort of feel a little bit like throwing red meat to the angry netizens and particularly felt so alarming because of the man's job, which ostensibly is to encourage dialogue between China and the outside world," said Jeremy Goldkorn, who runs a website that tracks the media and the Internet in China.
This "paranoid fear about spies and stealing our women — it does recall the vocabulary of racists everywhere," Goldkorn said.
China's nationalism occasionally bubbles over into xenophobia. Scores of foreign missionaries were slaughtered in the 1900 anti-West Boxer Rebellion. Chinese youth beat up foreign diplomats during the 1966-76 Cultural Revolution.
"This is a country that could be turned xenophobic very quickly, because people in school are still taught about the Opium Wars and all the unfairness that has happened in the past," said McGregor, who called the rising nationalism "worrisome."
"China needs to be connected to the world, and foreigners have had goodwill towards China. Why would you want to squander that? It's very short-sighted and could be quite damaging," he said.
Some foreign actions help fuel Chinese suspicions, such as when the U.S. Embassy in Beijing provided shelter to Chen Guangcheng, the blind activist who fled abusive house arrest in his rural village.
"Morally correct or not, the U.S. was actually engaged in an incredibly provocative act," said Bill Bishop, a Beijing-based Internet entrepreneur.
Many Chinese also resent what they consider lenient treatment for visitors when they misbehave.
Last week, a Russian cellist with a Beijing symphony was caught on a widely circulated video hurling vulgarities at a Chinese woman on a train who complained about his feet on her chair. A security official is seen telling passengers to let him be because "he's a musician."
"Many Chinese feel like foreigners have been given too much leeway in this kind of situation," said Dali Yang, a political scientist at University of Chicago Center in Beijing.
The cellist was later fired by the symphony, state media reported Tuesday.
Meanwhile, CCTV has distanced itself from Yang Rui's comments, calling them "personal actions."
He issued a statement Monday via state media explaining that the "foreign trash" in his microblog post were people like the British man in the alleged sexual assault and the Russian cellist.
"I want to separate them from the silent majority in the expat communities who obey and respect our culture and society," Yang Rui said.
"My post on May 16th is a wake-up call," he wrote. "Western or Chinese, no one should be above the law."
Follow Gillian Wong on Twitter at http://twitter.com/gillianwong