North Korea has released detained US citizens Matthew Todd Miller and Kenneth Bae.
Matthew Todd Miller and Kenneth Bae are now on their way home.
Director of National Intelligence James Clapper travelled to North Korea and is accompanying the men back, the US has confirmed.
A third US citizen, Jeffrey Fowle, was freed last month and no Americans are now being held in North Korea.
President Barack Obama said he was “grateful” for their safe return.
He said it was “a wonderful day” for the men and their families.
The US had accused North Korea of using its citizens as pawns in a diplomatic game. Pyongyang denies the accusations.
James Clapper travelled to North Korea for direct talks with the authorities.
North Korea has released detained US citizens Matthew Todd Miller and Kenneth Bae
Barack Obama said: “I appreciate the director doing a great job on what was obviously a challenging mission.”
The US department of state said in a statement that it “welcomes the release of US citizens Kenneth Bae and Matthew Todd Miller from the DPRK [North Korea], where they have been held for two years and seven months, respectively”.
It added: “The United States has long called on DPRK authorities to release these individuals on humanitarian grounds. We join their families and friends in welcoming them home.”
One US official told Associated Press news agency that nothing was offered in return for the releases.
The official said that the releases had not changed the US view of North Korea’s nuclear program and that the North should show a serious commitment to denuclearization and improved human rights.
The US thanked Sweden, which serves as the US protecting power in North Korea, for its efforts in the releases.
Matthew Todd Miller, 24, had been sentenced to six years’ hard labor in September for what North Korean state media described as “hostile acts”.
He had been in custody since April 10 when, according to North Korean sources, he destroyed his tourist visa and demanded asylum.
Kenneth Bae, 42, had been arrested in November 2012 as he entered the north-eastern port city of Rason, a special economic zone near North Korea’s border with China.
He has been described as both a tour operator and Christian missionary. North Korea said he used his tourism business to form groups to overthrow the government.
Kenneth Bae was sentenced to 15 years’ hard labor in May 2013.
American citizen Matthew Todd Miller has been sentenced by a North Korean court to six years of hard labor for “hostile acts”, the state-run KCNA news agency has said.
Matthew Todd Miller, 24, was arrested in April 2014, shortly after arriving as a tourist.
The US accuses North Korea of using Matthew Todd Miller and two other detained Americans as pawns in a diplomatic game.
The North Korean authorities have not specified the charges against Matthew Todd Miller, but they claim he tore up his visa and demanded asylum.
During the trial, prosecutors said Matthew Todd Miller admitted having a “wild ambition” to spend time in a North Korean prison so he could find out about the country’s human rights situation, the AP reports.
Notes produced in court also suggested he had become a fugitive because he was involved with WikiLeaks, the organization that has leaked US state secrets.
After a 90-minute trial, the sentence was handed down and Matthew Todd Miller was handcuffed and led from the room, AP reports.
The White House has described securing the release of Matthew Todd Miller and the two other American citizens detained in North Korea as a “top priority”.
Matthew Todd Miller has been sentenced to six years of hard labor for hostile acts in North Korea (photo Reuters)
In the past the US has been able to negotiate the release of American detainees.
Notably two journalists who were held whilst filming a documentary in North Korea were granted a “special pardon” after former President Bill Clinton travelled to the country.
The US has offered several times to send Robert King, its special envoy for North Korean human rights issues, to Pyongyang to discuss the detainees, but these visits have been cancelled by North Korea.
Matthew Todd Miller of Bakersfield, California, had been in custody since April 10.
Little information has been released about him, and the US State Department said this was partly because he had not signed a Privacy Act Waiver, which allows information about him to be released to the public.
According to KCNA, Matthew Todd Miller tore up his tourist visa on arrival in the country and shouted that “he came to the DPRK [North Korea] after choosing it as a shelter.”
In a brief interview with CNN earlier this month, attended by North Korean officials, Matthew Todd Miller said: “I will say that I prepared to violate the law of the DPRK before coming here.”
He also said he deliberately committed his “crime”, although he did not specify what he had done wrong.
In a recent interview with Associated Press, all three American detainees appealed to the US government to send a high-ranking representative to negotiate about their freedom.
State department official Daniel Russel told Reuters last week that the US found North Korean treatment of its citizens “objectionable and distressing”.
“This is the way that they play,” he said.
“They use human beings, and in this case Americans citizens, as pawns.”
Jeffrey Fowle came to North Korea as a tourist but was arrested in May for allegedly leaving a Bible in a public place. North Korea considers the distribution or spreading of Christian information as incendiary.
Korean-American missionary Kenneth Bae, who was arrested in November 2012, is serving 15 years in a labor camp after being convicted of trying to overthrow North Korea’s government.
Two American tourists detained in North Korea have pleaded for the US government to help secure their release.
Matthew Todd Miller and Jeffrey Fowle told the AP news agency they expected to be tried soon and given long prison terms.
The two men said they were in good health and had been treated well but expected conditions to get worse.
They were detained separately in April but both were accused of “committing hostile acts” while in the country.
Matthew Todd Miller and Jeffrey Fowle have pleaded for the US government to help secure their release
Jeffrey Fowle, 56, entered North Korea on April 29 and was detained in early June as he was leaving the country
He is said to have left a bible in the toilet of a restaurant in the northern port city of Chongjin but his family have insisted that he was not on a mission for his church.
North Korean authorities say Matthew Miller, 24, entered the country on April 10 with a tourist visa but tore it up at the airport and shouted that he wanted to seek asylum.
Speaking for the first time since being detained more than three months ago, Matthew Miller said: “The horizon for me is pretty dark. I don’t know what the worst-case scenario would be, but I need help to extricate myself from this situation. I have been requesting help from the American government, but have received no reply.”
It is unclear whether North Korean officials were in the room at the time of the interview or if the men were being coerced.
Authorities say they are preparing to bring them before a court, but the charges or potential punishment have not been specified. The date of the trial has not been announced.
North Korea has in the past been accused of using arrested Americans as diplomatic bargaining chips.
North Korea has announced that it will put detained US citizens Matthew Todd Miller and Jeffrey Fowle on trial, accusing them of “committing hostile acts”.
Matthew Todd Miller and Jeffrey Fowle had been investigated and would be brought before a court, the state news agency KCNA reported.
North Korea said that suspicions about the two men had been confirmed by evidence and the pair’s own statements, but gave no further details.
Another US citizen, Kenneth Bae, is currently serving a 15-year sentence.
Kenneth Bae was arrested in November 2012 and later convicted of trying to overthrow the North Korean government.
US attempts to secure Kenneth Bae’s release have so far proved unsuccessful, despite fears over his health.
Matthew Todd Miller and Jeffrey Fowle entered North Korea on tourist visas.
US citizen Jeffrey Fowle was arrested in North Korea because he left a Bible at a hotel
Jeffrey Fowle, 56, entered North Korea on April 29 and was detained in early June as he was leaving the country, according to North Korean reports.
Japanese agency Kyodo said Jeffrey Fowle was arrested because he left a Bible at a hotel.
Matthew Todd Miller was detained on April 10, KCNA reported.
The North Korean state agency said Matthew Todd Miller had torn up his tourist visa, shouting that he had “come to the DPRK [Democratic People’s Republic of Korea] after choosing it as a shelter”.
North Korea has in the past been accused of using arrested Americans as diplomatic bargaining chips.
The US wants Pyongyang to abandon its nuclear ambitions in return for economic and diplomatic incentives, but talks on a deal agreed in 2007 have been stalled for several years.
Last year, North Korea carried out its third nuclear test and launched a three-stage rocket that Washington called a banned test of long-range missile technology.
The US has no formal diplomatic ties with North Korea. But in the past, senior US figures including former President Bill Clinton have travelled to North Korea to ensure the release of American detainees.
Religious activity is severely restricted in North Korea and missionaries have been arrested on many previous occasions.
Kenneth Bae, the highest-profile of the currently detained Americans, was sentenced to 15 years’ hard labor in May 2013.
North Korea says Kenneth Bae used his tourism business to form groups to overthrow the government.
The US has tried on at least two occasions to arrange a visit by a senior human rights envoy, Robert King, to discuss his case, but Pyongyang has cancelled both these visits.
Detainees from other nations can be treated differently – earlier this year, Pyongyang deported Australian missionary John Short, who was detained after apparently leaving Christian pamphlets at a tourist site.
Also on Monday, North Korea proposed a suspension in hostilities and slander between the two Koreas.
The proposal comes after a volley of short-range missile launches by North Korea, and just days ahead of a visit to Seoul by Chinese President Xi Jinping.