Al-Qaeda terrorists in Afghanistan could threaten the United States (US) in as little as 12 months warned top US General Mark Milley
The Taliban had not broken ties with the group responsible for 9/11 and themselves remained a terror organisation, Gen Milley said.
He and Defence Secretary Lloyd Austin are being questioned in Congress about last month's pullout from Afghanistan, reports BBC.
The government collapsed as the Taliban rapidly advanced through the country.
Senator and committee leader Jack Reed said lawmakers wanted to understand whether the US "missed indicators" of the government's collapse.
The US has said it will now move towards counter-terrorism missions, reports BBC.
The hearing, held by the Senate armed services committee, comes weeks after a chaotic withdrawal at Kabul airport as foreign powers sought to get their citizens home and thousands of desperate Afghans begged for rescue.
A suicide attack killed 182 people during the withdrawal operation. Thirteen US service personnel and at least 169 Afghans were killed by the airport gate on 26 August.
Tuesday's hearing began with opening testimony from Defence Secretary Lloyd Austin followed by Gen Milley, reports BBC.
Gen Milley said the US would have to continue to protect its people from terrorist attacks from Afghanistan, and that mission would now be harder.
"The Taliban was and remains a terrorist organisation and still has not broken ties with al-Qaeda," he said.
"A reconstituted al-Qaeda or ISIS [Islamic State group] with aspirations to attack the US is a very real possibility, and those conditions to include activity in ungoverned spaces could present themselves in the next 12-36 months."
Another US general, Kenneth McKenzie, is also appearing. As head of US Central Command, he oversaw the withdrawal from Afghanistan.
The three men are now answering questions from members of Congress.
US troops first entered Afghanistan in late 2001, shortly after the 9/11 attacks. By the time they left, the US had spent about $985bn (£724bn) and deployed tens of thousands of troops, peaking at 110,000 in 2011.
In the weeks between the fall of Kabul and the withdrawal deadline of 31 August, the US evacuated its remaining 4,000 troops. It is also taking about 50,000 Afghan refugees who were airlifted out of Kabul.
As many as 20 people died in the crowds which gathered at the airport in the days after the Taliban takeover, reports BBC.
Gen Milley is facing tough questioning, especially from Republicans, who have called for him to be sacked.
He and Gen McKenzie will probably be asked about a US drone strike in Kabul on 29 August which killed 10 innocent members of a single-family.
After the attack, Gen McKenzie said US intelligence had tracked a car belonging to one member of the family, an aid worker, believing it was linked to a branch of the Islamic State (IS) group.
Gen Milley originally described the attack as a "righteous strike". After the Pentagon established that the dead were all civilians, he backtracked, admitting that he had spoken too soon.
It emerged recently that he held phone conversations with the Chinese military following concerns about then-President Donald Trump, reports BBC.
The phone calls were revealed in a book by journalist Bob Woodward, who also said Gen Milley had told his staff that if Mr Trump ordered a nuclear strike, then he would have to confirm it before it was carried out.
A spokesman for Gen Milley defended the calls, saying they were part of his duty to maintain "strategic stability".
Top Republican Senator Marco Rubio described this as "treasonous".