WASHINGTON—The U.S. and Uzbekistan have reached an agreement to transfer a group of Afghan Air Force pilots and their relatives to a U.S. military base as soon as this weekend, people familiar with the matter said.

The Uzbek government has been under intense pressure by the Taliban in Afghanistan to hand over the pilots, who flew themselves and relatives to safety in Uzbekistan aboard Afghan Air Force helicopters and airplanes.

The U.S. effort to train and build an Afghan Air Force was among the most celebrated programs in support of the country’s military. The U.S. spent billions of dollars on the air force, including on training, maintenance and the supply of dozens of helicopters and planes.

Taliban slogans have replaced murals of women activists, street vendors started selling the Islamic Emirate's flag, and protests broke out for several days in a row. WSJ's Yaroslav Trofimov looks at Kabul's rapid transformation after the fall of the republic. Photo Composite: Michelle Inez Simon The Wall Street Journal Interactive Edition

Among the Taliban, the pilots have been among the most hated members of the Afghan forces for their role in carrying out airstrikes against Taliban forces. While the Taliban have promised amnesty to government officials and forces, the pilots fear for their and their families’ safety.

Still in question is the fate of the 46 aircraft that landed at Termez airfield in Uzbekistan near the border with Afghanistan. These include U.S.-supplied Black Hawks and PC-12 surveillance aircraft, along with Soviet-era MI-17s.

The Taliban are calling for the aircraft to be returned to Afghanistan, a move likely to be strongly opposed by the U.S. Uzbekistan has carefully hedged relations between global powers in the region and has privately urged the State Department to resolve the issue as soon as possible.

The Taliban criticized the decision.

“These pilots should return to their country, the country needs them,” said spokesman Suhail Shaheen. “We are just starting to rebuild our country. The world should help us, instead of hurling hurdles in the way of reconstruction of Afghanistan and economic prosperity of our people.”

The State Department declined to comment. Uzbek officials in Washington declined to comment.

The expected transfer from Afghanistan prompted relief on Capitol Hill, where the pilots had drawn support from lawmakers who had served in the military. But the reaction also pointed to continued frustration with the Biden administration’s handling of the Afghan exit within Congress, which returns from a recess this month and is expected to hold hearings on the chaotic withdrawal.

“Through a lot of diligent work, we are hopeful that the pilots and military personnel, including the husband one of my constituents, are going to get out of Uzbekistan this weekend,” said Rep. August Pfluger (R., Texas). “This was accomplished through constant work to hold the Biden administration’s feet to the fire.”

The Uzbek government maintained relations with the Taliban for years prior to the Taliban’s seizure of Kabul last month, capping a sweeping offensive that captured most cities across Afghanistan with barely a shot fired.

The presence of the pilots, crews and their families in Uzbekistan, totaling some 585 people, has been a problem for the Uzbek government since their arrival.

The Afghans are expected to fly to the U.S. military’s base in Doha, Qatar, where they will be processed for onward travel. It wasn’t immediately clear whether the group would ultimately be transferred to the U.S. or elsewhere.

Write to Jessica Donati at jessica.donati@wsj.com and Siobhan Hughes at siobhan.hughes@wsj.com