Three American prisoners freed by North Korea were flying back to the United States on Wednesday, heading toward an air base where President Trump planned to personally welcome them home as he celebrates a diplomatic breakthrough in advance of nuclear talks.

The three prisoners, all American citizens of Korean descent, were described as healthy and able to walk on their own after months of imprisonment by one of the world’s most repressive governments. They were scheduled to land at 2 a.m. Thursday at Joint Base Andrews outside Washington, where Mr. Trump intended to greet them.

The release of the three Americans removed a bitter and emotional obstacle ahead of a planned summit meeting between Mr. Trump and Kim Jong-un, the North Korean leader. The move represented North Korea’s most tangible gesture since Mr. Trump took office aimed at improving relations with the United States after nearly seven decades of mutual antagonism.

“Nobody thought this was going to happen, and if it did, it would be years or decades, frankly,” Mr. Trump said at a cabinet meeting at the White House shortly after the three were released. “Nobody thought this was going to happen. And I appreciate Kim Jong-un for doing this and allowing them to go.”

The three were handed over to Secretary of State Mike Pompeo, who made a 13-hour visit to Pyongyang to finalize details of the coming presidential meeting. Mr. Pompeo said that the meeting would last one day and that the two sides had settled on the date and venue, but he did not disclose details.

Mr. Trump said it would not be held in the Demilitarized Zone between North and South Korea, as he earlier had suggested, and speculation focused on Singapore, a neutral site that has better facilities and is close to North Korea. The president said the details would be announced in three days.