Confirmation of Kim Jong-un's visit follows speculation about a mystery green train used by high-ranking North Korean officials spotted by Japanese media in China.
During the four-day visit which came at the invitation of Xi Jinping, Kim held talks with the Chinese president who hosted a banquet to welcome the North Korean leader and his wife Ri Sol Ju, Xinhua said.
"I have had successful talks with General Secretary Xi Jinping on developing relations between the two parties and the two countries, our respective domestic situation, maintaining peace and stability on the Korean Peninsula, and other issues," Kim said at the banquet, according to Xinhua.
US says visit is evidence pressure on NK is working
The North Korean leader arrived on Sunday, but China waited until now to publicly confirm the visit, shortly after briefing the White House.
A statement from the White House said the Trump administration sees the development "as further evidence that our campaign of maximum pressure is creating the appropriate atmosphere for dialogue with North Korea".

The green train used by North Korea to travel to Beijing. Source: Reuters
The historic four-day trip to China comes ahead of proposed summits with Seoul and Washington that could unsettle nuclear-armed Pyongyang's sole ally.
Relations between China and North Korea had soured as Beijing has backed tough United Nations sanctions to punish Pyongyang for its missile and nuclear tests.

Kim Jong-un has met with China's leader. Source: AP
Analysts had earlier suggested Beijing had been sidelined by Pyongyang's approaches to Seoul and Washington, but Kim's visit puts China firmly back at the centre of the diplomatic scrum.
"Both Comrade Chairman and I have personally experienced and witnessed the development of China-DPRK relationship," Xi said, using the initials for North Korea's official name.
"This is a strategic choice and the only right choice both sides have made based on history and reality.... This should not and will not change because of any single event at a particular time," Xi said.
Kim had not met Xi since the young North Korean leader took over after the death of his father, Kim Jong Il, in 2011.