BEIJING — President Xi Jinping of China plans to make his first state visit to North Korea this week, a surprise move that could rattle his relationship with President Trump, who has twice met the North’s leader, Kim Jong-un, and made his nuclear diplomacy with Mr. Kim a signature foreign policy project.

Mr. Kim has traveled to China four times in the past 15 months to confer with the Chinese president. But Mr. Xi, 66, who is one of the most traveled Chinese leaders, had been reluctant to reciprocate before now, depriving the 35-year-old Mr. Kim of the prestige of playing host to his most powerful neighbor.

By going to Pyongyang, the North’s capital, Mr. Xi is injecting himself into the middle of Mr. Trump’s negotiating efforts, which have languished since February when he and Mr. Kim failed to agree on a disarmament deal in Hanoi, Vietnam. Several analysts said they expected Mr. Xi to try to revive those talks during his two-day visit, on Thursday and Friday.

He could then deliver a plan for the next phase of the nuclear negotiations to Mr. Trump in Osaka, Japan, where he and the American president are expected to meet on the sidelines of a Group of 20 summit meeting.