China's president, Xi Jinping, arrives for the third plenary session of the National People's Congress in Beijing on March 12. (Tyrone Siu/Reuters)

More than half a century ago, hundreds of thousands of Chinese troops died in the Korean War, fighting on the side of their communist allies in the North against the U.S.-backed South. Yet today, China finds itself in the uncomfortable position of falling out with both sides on the Korean Peninsula.

On Monday, South Korea announced that it would press ahead with the “swift deployment” of a U.S. missile defense system despite vociferous Chinese opposition.

In February, China said it was cutting off coal imports from North Korea in accordance with sanctions imposed by the U.N. Security Council in a bid to persuade the North to abandon its nuclear and missile program. On Sunday, North Korea ignored China’s pleas not to raise regional tensions by conducting another missile test, albeit one that failed.

China has also imposed unofficial and unilateral sanctions against South Korea to persuade it not to deploy the missile defense system, experts say. On Monday, as Vice President Pence warned North Korea not to test U.S. resolve, South Korea’s acting president, Hwang Kyo-ahn, vowed to rapidly deploy that system, known as Terminal High Altitude Area Defense (THAAD).

(The Washington Post)

“Even before the United States upped the tempo, China was in the unusual position of having really very bad relations with both the North and the South — that’s something of an accomplishment,” said Euan Graham, director of the International Security Program at the Lowy Institute in Sydney. “Its peninsula policy was in tatters, and things have only got worse since.”

China is not alone in struggling to construct a successful policy toward North Korea, as the United States can attest. But the failure of its approach has seldom been more starkly outlined, as Pyongyang presses ahead with its nuclear program, the United States sends an aircraft carrier strike group to the region and fears of military conflict mount, analysts say.

Beijing and Washington share the same goal — a peninsula free of nuclear weapons — but they often appear to be trying to realize that goal in mutually incompatible ways.

Under President Barack Obama, the United States tried to isolate and pressure North Korea economically, an approach that China argues has raised tensions and forced its leader, Kim Jong Un — and his father before him — into a corner.

China had banked on a different approach, believing that building up North Korea’s economy would gradually bring about more moderate politics. That policy, though, has simply given North Korea the resources and the technology to build up its nuclear and missile programs, experts say.

Nor has it brought Beijing the leverage it desires: Kim has never met Chinese President Xi Jinping, and channels of communication between the two governments have never been thinner, experts say.

“China’s hope-based approach has encountered Kim Jong Un’s ‘I’ll have my cake and eat it’ approach,” Graham said. “What’s changed in the political relationship is Kim Jong Un’s total willingness to humiliate China, to slap it in the face, not to give China even the ritual obeisance his father did.”

China believes that the deployment of THAAD, with its sophisticated radar and missile defense capabilities, on its doorstep will allow the United States to spy on it and undermine its national security interests.

It has whipped up nationalist outrage against South Korea over the issue, with the sale of package tours to the country abruptly halted in March and tourist numbers plunging. State-run media has called for boycotts of South Korean businesses and goods, and primary-school children have even been encouraged to stage protests. South Korean films were barred from a recent international movie festival in Beijing, and music videos were blocked on streaming services.

Lotte, a South Korean conglomerate that turned over land for THAAD use, has faced huge losses as 87 of its 99 stores in China reportedly have been closed, mostly for ostensibly breaching fire regulations.

But even as Beijing tries to persuade Seoul to cancel the deployment of THAAD, Pyongyang shows utter disregard for China’s interests by launching missile after missile, making the case for the defense system ever stronger.

Now, Beijing has a new headache — brinkmanship not just from Kim but also from President Trump, experts say, with the threat of U.S. military action against North Korea on the table.

There is little doubt this has focused minds in Beijing.

Trump spoke to Xi about North Korea by telephone last week. He later said that China is “working with us on the North Korean problem.”

But despite its frustration with Pyongyang, is Beijing really prepared to turn up the heat on its old ally?

There appear to be some within the Communist Party who think it should.

The nationalist Global Times newspaper argued in an editorial Sunday that China should send a clear message to North Korea: If you conduct a sixth nuclear test, we will cut off the vast majority of your oil imports, through stiffer U.N. sanctions.

Shi Yinhong, a professor of international relations at Renmin University of China, said Beijing is “still hesitant” to take such a radical step, one that would threaten the fuel supplies that keep the North Korean military running.

Indeed, if the United States continues to turn up the heat, with more verbal threats or an even more robust naval presence, China could flip the other way, Shi argues — decide that Washington is the real threat to stability on the peninsula and “shift from suppressing North Korea to opposing the United States.”

Even though coal imports from North Korea appear to have been cut, and Air China canceled some direct flights between Beijing and Pyongyang this week, overall imports and exports between the two countries were up sharply in the first quarter of this year, data released by Chinese customs showed.

In the final analysis, some experts say, the legacy of the Korean War and the survival of the regime China backed at the cost of so much blood remain paramount.

“China may marginally increase economic pressure on North Korea by cutting down trade, tourist flows or food aid, but its primary goal is to placate Washington,” said Yanmei Xie, a politics and foreign policy expert at Gavekal Dragonomics. “Beijing has reasons and means to discipline Kim but is more concerned with ensuring the survival of his regime, thus maintaining a buffer against U.S. military presence in the South.”

Congcong Zhang contributed to this report.