TACOMA, Washington — Two Americans freed from secretive North Korea stepped off a plane into the welcoming arms of family on Saturday after the surprise involvement of the top-ranking U.S. intelligence official who traveled to Pyongyang to bring them home.

Kenneth Bae and Matthew Todd Miller, who had been doing hard labor for months in North Korea, were accompanied on their journey home by Director of National Intelligence James Clapper, a senior U.S. official said. Their release comes less than three weeks after another American was freed by Pyongyang.

The two men arrived at Joint Base Lewis-McChord near Tacoma in Washington state on a Boeing C-40 Clipper aircraft bearing the words “United States of America.”

A smiling Bae exited the aircraft and in an emotional reunion on the tarmac greeted his mother, sister, brother-in-law and two young nieces. Miller followed minutes later and also hugged family members. Both men had close-cropped hair.

Bae, 46, a Korean-American missionary from Lynnwood north of Seattle, was arrested in North Korea in November 2012 and sentenced to 15 years hard labor for crimes against the state. Miller, in his mid-20s, was reportedly convicted on an espionage charge and in custody since April, serving a six-year hard labor sentence.

Bae thanked President Barack Obama and the North Korean government for his freedom and said he appreciated the thoughts and prayers of people who supported him.

“It’s been an amazing two years, I learned a lot, I grew a lot, lost a lot of weight — in a good way — but I’m standing strong because of you and thank you for being there in such time as this,” Bae said at a news conference.

When asked about his health, Bae said he was still recovering. His family had expressed concern about his well-being during his detention, saying he had diabetes, an enlarged heart, deteriorating vision and back and leg pains. Miller did not speak to reporters.

The United States had frequently called for the men to be freed for humanitarian reasons, especially given Bae’s health problems.

CNN reported the North Korean government issued a statement about the release, saying it received an “earnest apology” from Obama for the men’s actions. It also said the two were “sincerely repentant of their crimes and [were] behaving themselves while serving their terms.”

According to the statement, the first chairman of North Korea’s National Defense Commission, the country’s leader, Kim Jong Un, ordered the release.

North Korea, already under international sanctions for its nuclear and missile programs, has been on a diplomatic campaign to counter charges by a U.N. body that highlighted widespread human rights abuses and a move by some U.N. members to refer the state to an international tribunal. But it was not clear what prompted Pyongyang to free the two men at this time.

Their release did not constitute an opening in relations with North Korea, said a senior State Department official, who declined to be identified. The official said for that to happen, Pyongyang must fulfill its commitments on denuclearization and human rights.

“[Clapper] was not there to negotiate. And our position hasn’t changed,” an official said.

The men were released just hours before Obama was to start a trip to Asia that will include talks with Chinese leaders about how Beijing can use its influence with North Korea to rein in its nuclear weapons program, U.S. officials have said.

“It’s a wonderful day for them and their families,” Obama said at the White House. “Obviously we are very grateful for their safe return, and I appreciate Director Clapper doing a great job on what was obviously a challenging mission.”

A senior U.S. official said: “[Clapper] did carry a brief message from the president indicating that Director Clapper was his personal envoy to bring the two Americans home.”

Bae’s delighted son, Jonathan, told Reuters from Arizona that he received a call Friday night and spoke to his father.

“One minute he was doing farm labor and the next minute they are saying, ‘You are going home.’ Just like everyone else, he was surprised,” he said.

As director of national intelligence, a job created after the Sept. 11, 2001, attacks on the United States, Clapper oversees the CIA and some 15 other intelligence agencies, making his trip to Pyongyang surprising. U.S. officials said it was the first time a national intelligence director had been involved in such a high-profile diplomatic matter.

Arrangements for the release had come together in the past several days and North Korea had asked for a high-ranking envoy to be involved, the official said.

Clapper did not personally meet Kim Jong Un, but he met with a number of North Korean security officials during the roughly one day he was in the country, a senior U.S. official said.

The men’s release came just a few weeks after North Korea freed another American, Jeffrey Fowle, 56 — a street repair worker from Miamisburg, Ohio, who had been arrested in May for leaving a Bible in a sailor’s club in the North Korean city of Chongjin, where he was traveling as a tourist.

U.N. Secretary-General Ban Ki-moon welcomed the release, his office said in a statement, adding, “The secretary-general hopes that this positive momentum for improving relations among the concerned parties for peace and security on the Korean Peninsula and beyond will be built on.”

Victor Cha, of the Center for Strategic and International Studies, said the release could indicate North Korea wants to press Obama on the eve of his Asian trip and that Pyongyang is feeling international heat from the U.N. resolution.

“This is worrying to them,” Cha said. “They have never seen anything like this before. Moreover, it is not coming from the U.S. but from the entire international community. They are trying to blunt criticism and perhaps water down the resolution with these actions.”

Miller of Bakersfield, California, had gone to North Korea on a tourist visa, which state media said he tore up while demanding Pyongyang grant him asylum.

The Associated Press reported Miller was tried on an espionage charge, and prosecutors at his trial said he had falsely claimed to have secret information about the U.S. military stationed in South Korea.

Bae’s family said on its website that Bae had operated from China since 2006 and led more than a dozen tours of North Korea.

“Even tonight as we were reunited, he said to me ‘I’m so happy to be here but my heart aches for the people of North Korea,’” Bae’s sister, Terri Chung, told reporters.