North Korean leader Kim Jong Un visited China from Sunday to Wednesday on an unofficial visit, China's state news agency Xinhua reported on Wednesday.
The visit, confirmed by China and North Korea, was Mr Kim's first foreign trip since taking office in 2011. And is believed by analysts to serve as preparation for upcoming summits with South Korea and the United States.
Beijing has traditionally been the closest ally of secretive and isolated North Korea, but ties have been frayed by North Korea`s pursuit of nuclear weapons and China`s backing of tough U.N. sanctions in response.
Xinhua published a photograph of Kim and Xi shaking hands in front of the flags of the two nations.
Speculation about a possible visit by Kim to Beijing was rife earlier this week after a train similar to the one used by Kim`s father was seen in the Chinese capital, along with heavy security and a large motorcade.
South Korea's Yonhap news agency reported that Kim visited China from Sunday to Wednesday with his wife, Ri Sol Ju. It cited North Korea without elaborating.
Xi had accepted an invitation from Kim to visit North Korea, Yonhap said.
Improving ties between North Korea and China would be a positive sign before planned summits involving the two Koreas and the United States, a senior South Korean official said on Tuesday.
Kim Jong Un's father, Kim Jong Il, met then-president Jiang Zemin in China in 2000 before a summit between the two Koreas in June that year. That visit was seen at the time as a reaffirmation of close ties with Beijing.