American Kevin King and Australian Timothy Weeks, who had been held since 2016, were released in exchange for three top Taliban figures.
The president was in town for a closed-door fundraiser and a speech to the International Association of Chiefs of Police.
So far this year, 2,000 U.S. troops have been withdrawn, leaving 12,000 behind, the top American commander in Afghanistan said Monday.
Hours later, an explosion struck near the U.S. embassy in Kabul. The violence comes as Afghanistan faces presidential elections on Sept. 28.
He "found out the Taliban kill people" just before the anniversary of 9/11, one wag scoffed.
The Taliban took credit for a car bombing in Kabul as they and the U.S. engage in peace talks meant to reduce U.S. military presence in Afghanistan.
The explosions occurred in public squares, markets and outside restaurants in the city of Jalalabad.
Afghan and international forces killed more than 700 civilians in the first six months of the year.
The attack against the Green Trend party headquarters lasted for hours and claimed the lives of at least 20 people.
Federal prosecutors say Delowar Mohammed Hossain, 33, was trying to get to Afghanistan so he could kill U.S. soldiers through the Islamic group.
A tussle between Reps. Tim Ryan and Tulsi Gabbard over Afghanistan shows the party isn't yet being honest about what it does when it gains power.
Seen as a rising Democratic star, he dropped out of Kansas City, Missouri, mayor's race last year.
"Some of you will join the fight on the Korean Peninsula ... where North Korea continues to threaten the peace," the vice president said.
The mounting challenges show the limits of Trump's self-touted ability to make a deal.
They've risked their lives working for the American military abroad, yet the number of interpreters being granted U.S. visas has fallen sharply.
Afghan forces and their allies were responsible for more than half of all civilian deaths in the first three months of 2019.
The Taliban claimed responsibility for the attack, which left three American soldiers dead and one Afghan contractor injured.
The fatalities bring to four the number of U.S. soldiers killed so far this year in Afghanistan.