Washington: US soldier Travis King has been freed by North Korea, where he had been held since running across the border from the South in July, the White House said on Wednesday.
North Korea's state news agency had made a surprise announcement just hours earlier that Pyongyang had decided to expel King, who crossed over during a sightseeing tour of the Demilitarized Zone.
The White House thanked Beijing for allowing the 23-year-old to leave through China, with officials saying King had now left Chinese airspace after being handed over to US custody there.
King was in "good health and good spirits" and looking forward to coming home, after heading to a US military airbase first, US officials added.
"US officials have secured the return of Private Travis King from the Democratic People's Republic of Korea (DPRK)," National Security Advisor Jake Sullivan said in a statement
Sullivan thanked Sweden, which acts as Washington's diplomatic liaison in Pyongyang, "and the government of the People's Republic of China for its assistance in facilitating the transit of Private King."
Pentagon spokesman Pat Ryder hailed the "hard work" of US military forces and the State Department in getting King home.
After a drunken pub fight, an incident with police and a stay in South Korean jail, Private Second Class King was being taken to the airport in July to fly back to Texas.
But instead of travelling to Fort Bliss for disciplinary hearings, King snuck away, joined a Demilitarised Zone sightseeing trip and slipped over the border.
Last month, Pyongyang confirmed it was holding the US soldier, saying King had defected to North Korea to escape "mistreatment and racial discrimination in the U.S. Army".
But after completing its investigation, Pyongyang has "decided to expel Travis King, a soldier of the U.S. Army who illegally intruded into the territory of the DPRK, under the law of the Republic", the Korean Central News Agency said Wednesday, using the North's formal name.
The US soldiers' release followed a complex, "months-long" diplomatic effort, a senior US administration official said on condition of anonymity.
King was "transferred out of the DPRK across the border to China, with the help of the government of Sweden. The United States has been able to receive him in China and is now in the process of transferring him home," the official said.
King's motives remained unclear for going to a country that has a long history of detaining Americans and using them as bargaining chips in bilateral negotiations.
His border crossing came with relations between the two Koreas at one of their lowest points ever, with diplomacy stalled and North Korean leader Kim Jong Un calling for increased weapons development, including tactical nuclear warheads.
Seoul and Washington have ramped up defense cooperation in response, staging joint military exercises with advanced stealth jets and US strategic assets.
The two Koreas remain technically at war because the 1950-53 conflict ended in an armistice, not a treaty, and most of the border between them is heavily fortified.
But at the Joint Security Area where King made his escape, the frontier is marked only by a low concrete divider and is relatively easy to cross, despite the presence of soldiers on both sides.
One of the last US citizens to be detained by the North was student Otto Warmbier, who was held for a year and a half before being released in a coma to the United States. He died six days later.
Around half a dozen American soldiers made rare defections to the North after the Korean War and were used for the country's propaganda.
In one such case, US soldier Charles Robert Jenkins crossed into the North in 1965, drunk after 10 beers, while patrolling the DMZ in an attempt to avoid facing combat duty in Vietnam.
Although he quickly regretted his defection, Jenkins was held for decades, teaching English to North Korean soldiers and appearing in propaganda leaflets and films.
He was eventually allowed to leave in 2004 and subsequently spoke out about the dire conditions of life in the North until he died in 2017.