BEIJING — However isolated North Korea may be, it has long had one major ally: China. But for two years, China’s leader, President Xi Jinping, seemed to be favoring Pyongyang’s neighbor and nemesis to the south.

He spent much political capital wooing South Korea’s president, Park Geun-hye, in hopes of drawing the country away from its longtime ally, the United States. He made an elaborate state visit to Seoul while shunning North Korea and its young leader, Kim Jong-un, whom he has yet to meet. Ms. Park returned the favor last year, coming to Beijing for a major military parade at Tiananmen Square, the only leader of an American ally to attend.

But on Friday, it became clear that Mr. Xi’s efforts had fallen short. In announcing plans to deploy an advanced American missile defense system in South Korean, Ms. Park’s government showed that it was embracing its alliance with Washington more than ever, and that it would rely less on China to keep North Korea and its nuclear arsenal at bay.

In Beijing, the decision was seen as a major setback, one that went beyond its interests on the Korean Peninsula to the larger strategic question of an arms race in Northeast Asia that could impel China — and Russia — to develop more sophisticated weapons.