North Korean leader Kim Jong Un has completed his visit to Russia and passed through the North's border crossing at Tumangang Railway Station, according to state media.
The rare week-long trip included talks with Russian President Vladimir Putin on closer military and other cooperation.
The visit "further deepened the comradely fellowship and friendly ties with" Putin and "opened a new chapter of the development of" relations between North Korea and Russia, KCNA news agency said.
Before departing Russia, Mr Kim expressed his "heartfelt thanks" to President Vladimir Putin, state media reported.
His tour of the country's far east, which began last Tuesday, has fuelled Western fears that isolated, nuclear-armed North Korea could provide Russia with weapons for its war in Ukraine.
During the trip, Mr Kim inspected everything from space rockets to submarines and symbolically exchanged rifles with Mr Putin.
KCNA said Mr Kim "extended his heartfelt thanks to President Putin and the Russian leadership" for "their special care and cordial hospitality" as he wrapped up the visit.
He headed home "after successfully completing the schedule of his official goodwill visit to the Russian Federation," the report added.
He also wished "Russia prosperity and its people well-being", KCNA said.
North Korea and Russia, historic allies, are both under rafts of global sanctions - Moscow for its Ukraine invasion, Pyongyang for its nuclear weapon tests.
During his visit, Mr Kim said his country would make bilateral ties with Russia its "number one priority", as he held a rare summit with Mr Putin.
China is North Korea's most crucial ally and benefactor.
Russia is eager for North Korea's stockpile of artillery shells to be used in Ukraine, while Pyongyang is looking for help with satellite technology and upgrading its Soviet-era military equipment, experts say.