WASHINGTON (AP) — Three Americans detained in North Korea for more than a year are on their way back to the U.S. with Secretary of State Mike Pompeo, President Donald Trump announced Wednesday in the latest sign of improving relations between the two longtime adversary nations.

Trump said on Twitter that Pompeo was "in the air" and was with "the 3 wonderful gentlemen that everyone is looking so forward to meeting." The president, who had been hinting about an imminent release, said he would greet them at Andrews Air Force Base at 2 a.m. Thursday.

The release of the detainees came as Pompeo visited North Korea on Wednesday to finalize plans for a historic summit between Trump and the North's leader, Kim Jong Un. Trump said on Twitter that there had been a "good meeting with Kim Jong Un," adding: "Date & Place set."

North Korea had accused Kim Dong Chul, Kim Hak Song and Tony Kim, all Korean-Americans, of anti-state activities but their arrests were widely seen as politically motivated and had compounded the dire state of relations over the isolated nation's nuclear weapons.

The family of Tony Kim thanked "all those" who worked for his return and also credited Trump for engaging directly with North Korea. "Mostly we thank God for Tony's safe return," the family said in a statement, and they urged people to "continue to pray for the people of North Korea and for the release of all who are still being held."

White House spokeswoman Sarah Huckabee Sanders said in a statement that Trump viewed the release "as a positive gesture of goodwill."

The release capped a dramatic day of diplomacy in Pyongyang for Pompeo. After his 90-minute meeting with Kim Jong Un, he gave reporters a fingers-crossed sign when asked about the prisoners as he returned to his hotel. But it was only after a North Korean emissary arrived a bit later to inform him that the release was confirmed.

The three had been held for periods ranging between one and two years. They were the latest in a series of Americans who have been detained by North Korea in recent years for seemingly small offenses and typically freed when senior U.S. officials or statesmen personally visited to bail them out.

The last American to be released before this, college student Otto Warmbier, died in June 2017, days after he was repatriated to the U.S. with severe brain damage.

Warmbier was arrested by North Korean authorities in January 2016. He was accused of stealing a propaganda poster and sentenced to 15 years in prison with hard labor. His parents have filed a wrongful death lawsuit, accusing the government of torturing and killing their son.

Of the newly released detainees, Kim Dong Chul, a South Korean-born U.S. citizen, had been held the longest. The former Virginia resident was sentenced in April 2016 to 10 years in prison with hard labor after being convicted of espionage. He reportedly ran a trade and hotel service company in Rason, a special economic zone on North Korea's border with Russia.

The other two detainees hadn't been tried.

Kim Hak Song worked in agricultural development at an experimental farm run by the Pyongyang University of Science and Technology, or PUST. The university is the only privately funded college in North Korea and was founded in 2010 with donations from Christian groups. He was detained last May for alleged anti-state activities.

Tony Kim, who also uses the name Kim Sang-duk, was detained in April 2017 at the Pyongyang airport. He taught accounting at PUST. He was accused of committing unspecified criminal acts intended to overthrow the government.

Pompeo, in his visit, discussed the agenda for a potential Trump-Kim Jong Un summit in his meeting with Kim Yong Chol, the vice chairman of the central committee of North Korea's ruling party.

The two sides plan to meet once again to finalize details. No specifics were offered although officials said Singapore is emerging as the most likely venue. The unprecedented meeting has been slated for this month or early June.

Kim Yong Chol noted improved relations between North and South Korea and pushed back against the idea that U.S. pressure led to the likely summit.

"This is not a result of sanctions that have been imposed from outside," he said. That contradicted Trump, who has said repeatedly that his pressure tactics brought North Korea to the negotiating table.

Pompeo's trip, his second to North Korea this year, had not been publicly disclosed when he flew out of Washington late Monday aboard an Air Force jetliner. Trump announced the mission Tuesday afternoon as he laid out his case for withdrawing from a landmark nuclear deal with Iran, another bitter U.S. adversary.

Accompanying Pompeo were a few senior aides, a security detail and two journalists — one from The Associated Press and one from The Washington Post.

Pompeo, who first traveled to North Korea as CIA chief in early April, is only the second sitting secretary of state to visit the reclusive nation with which the U.S. is still technically at war. The first was Madeleine Albright, who went in 2000 as part of an unsuccessful bid to arrange a meeting between then-President Bill Clinton and Kim Jong Un's father, Kim Jong Il.

A Trump-Kim meeting seemed a remote possibility just a few months ago when the two leaders were trading threats and insults over North Korea's development of nuclear weapons and ballistic missile tests. But momentum for diplomacy built this year as North and South Korea moved to ease tensions, including the North sending a contingent to the Winter Olympics in the South. The Koreas' leaders' held their own summit last month.

In March, Trump unexpectedly accepted an offer of talks from Kim after the North Korean dictator agreed to suspend nuclear and missile tests and discuss "denuclearization." According to South Korea, Kim says he's willing to give up his nukes if the United States commits to a formal end to the Korean War and pledges not to attack the North.

Kim was quoted by China's official news agency Xinhua as saying on Monday, "I hope to build mutual trust with the U.S. through dialogue." He added that a political resolution of tensions on the Korean Peninsula and denuclearization should proceed in stages, with all sides moving in concert.

But his exact demands for relinquishing weapons that his nation spent decades building remain unclear. Previous U.S. efforts to negotiate an end to the North's nuclear weapons program failed under Presidents Clinton and George W. Bush.

Pompeo and officials traveling with him said the Trump administration would not repeat mistakes of the past, which they described as accepting gradual, incremental and long-term disarmament in exchange for immediate benefits.

Trump has said that withdrawing U.S. forces from South Korea is "not on the table." Some 28,500 U.S. forces are based in the allied nation, a military presence that has been preserved to deter North Korea since the war ended in 1953 without a peace treaty.