The Chinese government is trying to repair damage to its ties with Malaysia after its criticism of an investigation into the disappearance of Malaysia Airlines Flight 370 unleashed an ugly bout of nationalism and upset a country it had been trying to woo.

The hallmark of Chinese President Xi Jinping’s foreign policy in his first year in office has been an attempt to improve relations with Southeast Asian countries such as Malaysia, Indonesia and Thailand, while trying to confront and isolate territorial rivals and key U.S. allies Japan and the Philippines.

The charm offensive has largely been concentrated on countries that Beijing feels it can pry out of Washington’s orbit with promises of lucrative trade deals and billions of dollars in infrastructure investment.

In October, Xi visited the Malaysian capital and spoke lyrically about historical ties and dreams of reviving a “maritime Silk Road.” China’s relationship with Malaysia was upgraded to a “comprehensive strategic partnership,” and in a traditional Chinese diplomatic gesture of friendship, two pandas were presented to a Malaysian zoo.

But the disappearance of Flight 370 ruptured those closely nurtured ties. Two-thirds of the 227 passengers on the Boeing 777 that went missing March 8 while en route from Kuala Lumpur to Beijing were Chinese.

Compare the depth of Malaysia Airlines Flight 370 to other milestone depths and distances.

With Beijing’s approval, anger at Malaysia’s handling of the investigation erupted on Chinese social media and even in the streets, and trust between the two governments collapsed.

Paul Haenle, director of the Carnegie-Tsinghua Center in Beijing, said he was struck by the depth of the anger and how some of it was directed at the Malaysian people.

“I was surprised because Malaysia is an important part of China’s charm offensive,” he said. “Chinese official reactions were quite strong, and that gave space for the Chinese people to pick up on that and run with it.”

From contempt to open anger

Within days of the plane’s disappearance, China’s Foreign Ministry was urging Malaysia to speed up its investigation and provide more accurate information.

The state-run Xinhua News Agency complained of an “unforgivable” lack of capacity, effort or transparency on the part of the Malaysian government, while nationalist tabloid the Global Times asked whether the Malaysian military was hiding something.

After Malaysia’s prime minister announced that the plane went down in the Indian Ocean, hundreds of relatives of those aboard vented their anger in a state-sponsored protest at the Malaysian Embassy in Beijing. Before it began, plainclothes police officers corralled the relatives onto buses, provided them with printed placards and T-shirts bearing slogans, and even lectured them on how to protest in an orderly fashion.

On social media, actor Chen Kun received hundreds of thousands of endorsements when he called the Malaysian government and airline “clowns” and “hooligans.” He said he would boycott Malaysia and its goods.

A black box emits high-frequency signals that can create a complicated pattern of sound waves under the surface.

The adjective “Malaysian” became a popular byword for irresponsibility and unreliability; Malaysian singers of Chinese descent were abused online.

Malaysia is an important Chinese tourist destination, but travel agencies suspended packages that included flights on Malaysian airlines. Further, netizens overwhelmingly said in opinion polls that they would never visit the country.

Finally, Malaysia’s patience broke.

After repeatedly insisting that his government was doing its best, Defense Minister Hishammuddin Hussein sounded distinctly peeved March 25 when he complained that the search had been distracted by Chinese satellite images of debris that proved to be unrelated to the missing plane.

James Chin, a professor of political science at Monash University in Australia, said that the Malaysians were initially sympathetic toward the Chinese but that the protest at the embassy marked a turning point.

“It’s hypocrisy,” he told the South China Morning Post. “The Chinese won’t dare do anything like this against their own government, which is one of the most opaque in the world.”

Handled ‘too heavily’

In the past, news of deadly accidents has often been played down in China as the government feared popular anger would be directed at the authorities. But in the Malaysia Airlines case, Beijing appeared to see an opportunity to ride that anger to bolster its own nationalist credentials, an important source of the Communist Party’s legitimacy.

“China handled it too heavily,” said Qiao Mu, who teaches international communications at Beijing Foreign Studies University. “It presented a very tough image, speaking out for its own people. But later on, it found it might have overreacted, so it tried to soften its tone and adjust its stance.”

As a result, Qiao said, the government then “turned to the usual tactics, blaming a foreign force or the Western media.”

In a stunning piece of historical revisionism, Huang Huikang, China’s ambassador to Malaysia, accused the Western news media of “spreading rumors” and “making use of the weak emotions of victims’ families to sow discord between Malaysia and China,” according to local media reports.

Apparently oblivious to its own editorial of just a few weeks earlier, the Global Times also rounded on Western media, saying they were attempting “to stir up” Sino-Malaysian relations. “Confusion” among Chinese people threatened the nation’s core interests, it wrote, but the Chinese government would not be swayed by populism or allow bilateral relations to be derailed.

Nevertheless, it was far from clear that the Malaysian government or its people would be assuaged by Beijing’s new approach.

“China has dug itself into a very deep hole with the Malaysians,” said Ernest Z. Bower, a Southeast Asia expert at the Center for Strategic and International Studies in Washington. It could take years to repair the damage, he said.

Gu Jinglu and Xu Jing contributed to this report.