North Korea's reclusive leader Kim Jong Il was at Pyongyang's airport on Sunday for Hu's departure, China's official Xinhua News Agency reported.
China is North Korea's last major ally, giving it what other governments consider to be unique leverage over the isolated country.
It was the first visit by a Chinese leader to North Korea since 2001. Hu returned to Beijing on Sunday morning, Xinhua said.
During his visit, Hu won a pledge from Kim that North Korea will take part in the next round of six-nation talks on the North's nuclear programme, to take place in November.
The Chinese-organised talks also involve the United States, South Korea, Japan and Russia.
At the same time, North Korea kept up its anti-US rhetoric, saying via its official Korean Central News Agency on Saturday that US pressure on human rights and other issues threatens the future of the talks.
Kim Jong Il said North Korea will
take part in the nuclear talks
Pyongyang promised at the last round of talks in September to give up its nuclear programme in exchange for aid and a security guarantee.
But it also raised doubts about its willingness to proceed, demanding a civilian nuclear reactor for power generation first.
Hu attended North Korea's famed mass games on Saturday night, China Central Television reported, showing footage of tens of thousands of performers dancing in unison in a giant stadium.
It showed Hu and Kim giving a standing ovation to the performers as fireworks lit up the night sky.
Hu also visited a North Korean glass factory financed by Beijing during his trip.
Xinhua quoted Hu as promising that China would encourage its companies to "carry out more cooperation" with the North's decrepit economy.