WASHINGTON — Donald Trump personally welcomed home three Americans released from detention in North Korea, a triumphant middle-of-the-night moment for the president as he prepares for a landmark summit with Kim Jong Un.

The three men flew to Washington after their release to Secretary of State Mike Pompeo, who was dispatched to Pyongyang on Tuesday in the hope that Kim would agree to free the detainees. Trump and his wife Melania boarded the former prisoners’ plane at Joint Base Andrews shortly before 3 a.m. on Thursday to greet the men.

The return of prisoners the U.S. has called “hostages” clears an obstacle to direct talks between Trump and Kim.

The president said on Wednesday that he expects to announce a date and location for the summit within days and that he had ruled out the Korea Peninsula’s Demilitarized Zone. An administration official later said that he is leaning toward Singapore.

Trump thanked Kim for releasing the men. “This is a special night for these three really great people and congratulations on being in this country,” Trump told reporters at the airbase.

The U.S. aims to persuade Kim to give up his country’s nuclear arsenal, and Trump has engaged in what he calls a “maximum pressure” campaign to ratchet up sanctions on North Korea and lean on other nations to cut diplomatic ties.

“I really think we have a very good chance of doing something very meaningful,” Trump said. “I really think he wants to do something and bring that country into the real world,” he said of Kim.

“The true honor is going to be if we have a victory in getting rid of nuclear weapons,” Trump said.

The former detainees are all Korean-American men who share the common surname Kim but are not related. They were handed over to Pompeo during his second trip to Pyongyang this year, a visit that wasn’t announced before Trump himself disclosed it on Tuesday while the secretary of state was in the air.

Asked if he might visit Pyongyang himself in the future, Trump said it “could happen.” He joked that the homecoming event would set a “3 a.m.” television ratings record.

“We would like to express our deep appreciation to the United States government, President Trump, Secretary Pompeo, and the people of the United States for bringing us home,” the detainees said in a statement as they flew to Washington. “We thank God, and all our families and friends who prayed for us and for our return. God Bless America, the greatest nation in the world.”

Kim Dong Chul was sentenced to 10 years hard labor in 2016 on charges he conducted espionage for South Korea. South Korea’s intelligence agency denied any ties to the man.

Kim Hak Song was detained last year for what North Korean media described as “hostile acts” against the country.

Kim Sang Dok, also known as Tony Kim, was intercepted in April 2017 at Pyongyang International Airport after being invited to teach accounting at Pyongyang University of Science and Technology.

The homecoming event was broadcast live on cable news networks, and the men were greeted by a large American flag strung between two fire trucks parked on the tarmac.

Pompeo was informed after a meeting with Kim Jong Un on Wednesday that the men had been granted “amnesty.” They were brought to the airport and left North Korea on Pompeo’s plane at about 8:42 p.m. local time on Wednesday. The secretary of state and the detainees arrived at Joint Base Andrews on Thursday on separate planes.

Vice President Mike Pence, who joined Trump at the homecoming, said Wednesday that all three men “seem to be in good health” and were glad to be heading home. Pence also spoke Wednesday with the parents of Otto Warmbier, the American college student who had been detained in North Korea for trying to steal a propaganda poster from a hotel. Warmbier died shortly after being returned home from North Korea in a coma last year.

After meeting Trump and Pence the former detainees boarded a bus to travel to Walter Reed military hospital in Bethesda, Maryland for evaluation and any treatment. Pence, meanwhile, said on Twitter he would sit for interviews with NBC, ABC and CBS to be broadcast on their morning news programs.