BEIJING — North Korea had detonated a nuclear bomb, and the president of China was urging caution. It was the fall of 2013, and the North’s third nuclear test in seven years, carried out several months earlier, had rattled much of the world.

But President Xi Jinping, in a private meeting with President Obama at Constantine Palace in St. Petersburg, Russia, warned against putting too much pressure on Kim Jong-un, the North’s young, volcanic leader.

“A barefoot person does not fear those who wear shoes,” Mr. Xi told Mr. Obama, invoking a Chinese proverb to convey that an impoverished nation like North Korea had nothing to lose by standing up to China and the United States. The conversation was recounted by an American diplomat familiar with the talks, who spoke on the condition of anonymity for fear of angering the Chinese.

Since coming to power in 2012, Mr. Xi has pushed the limits of Chinese foreign policy, challenging America’s influence in the Pacific and using China’s financial heft to win allies across the globe. But while Mr. Xi has taken a tougher approach than his predecessors on North Korea, he has resisted inflicting crippling punishments on the North, an ally for six decades and a valuable counterweight for Beijing to American military might in Asia.