Media playback is unsupported on your device Media caption A plane carrying the two men landed at a military base near Tacoma in Washington state

Two Americans who were released from detention in North Korea, Matthew Todd Miller and Kenneth Bae, have arrived back in the US.

US Director of National Intelligence James Clapper travelled to North Korea and accompanied 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.

US President Barack Obama said he was "grateful" for their safe return.

He said it was "a wonderful day" for the men and their families.

A plane carrying the two men landed at a military base near Tacoma in Washington state late on Saturday.

Image copyright AP Image caption Kenneth Bae (left) had been held for two years and Matthew Miller for seven months

Speaking to reporters at the Joint Base Lewis-McChord, Mr Bae thanked all those who had supported them and helped to bring them home.

"It has been a tremendously difficult time for my family," he said.

The US had accused North Korea of using its citizens as pawns in a diplomatic game. Pyongyang denies the accusations.

UN Secretary General Ban Ki-moon said he appreciated North Korea's decision to release the men and was relieved they were returning home.

Media playback is unsupported on your device Media caption Kenneth Bae: ''Thank you for standing by me''

'Hostile acts'

Mr Clapper travelled to North Korea for direct talks with the authorities.

Mr Obama said: "I appreciate the director doing a great job on what was obviously a challenging mission."

Analysis: BBC's Charles Scanlon

The release of the two remaining prisoners will raise hope of some diplomatic progress after a long period of deadlock between Pyongyang and Washington. Their release had been expected - only the timing was in doubt.

The leadership in North Korea would certainly see value in offering an olive branch to the US just before President Barack Obama prepares to sit down with Chinese President Xi Jinping in Beijing.

Washington needs Chinese help in referring a damning human rights report on North Korea to the International Criminal Court. Mr Xi has already gone further than any of his predecessors to show irritation with an old Communist ally.

The direct participation of Mr Clapper will raise eyebrows in the region. The state department is denying a deal was done, and the confrontation over North Korea's nuclear and missile programmes looks as intractable as ever.

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."

The son of Kenneth Bae told Reuters: "It's awesome. Couldn't be happier."

One US official told Associated Press news agency that nothing was offered in return for the releases.

Media playback is unsupported on your device Media caption President Obama: "We are very grateful for their safe return"

The official said that the releases had not changed the US view of North Korea's nuclear programme and that the North should show a serious commitment to denuclearisation and improved human rights.

The US thanked Sweden, which serves as the US protecting power in North Korea, for its efforts in the releases.

Mr Miller, 24, had been sentenced to six years' hard labour in September for what North Korean state media described as "hostile acts".

He had been in custody since 10 April when, according to North Korean sources, he destroyed his tourist visa and demanded asylum.

Mr 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.

He was sentenced to 15 years' hard labour in May 2013.

Image copyright AP Image caption Jeffrey Fowle, who reportedly left a Bible in a toilet, flew home in October

Jeffrey Fowle flew home to the US last month following negotiations.

Mr Fowle, 56, had entered North Korea in April and was detained in early June as he was leaving the country. He was charged with "anti-state" crimes.

He was reported to have left a Bible in the toilet of a restaurant in the northern port city of Chongjin.