WASHINGTON -- U.S. President Joe Biden said Wednesday he will withdraw remaining U.S. troops from the "forever war" in Afghanistan, declaring that the Sept. 11 terror attacks of 20 years ago cannot justify American forces still dying in the nation's longest war.

His plan is to pull out all American forces -- numbering 2,500 now -- by this Sept. 11, the anniversary of the attacks, which were co-ordinated from Afghanistan. Soon after Biden made his announcement, NATO chief Jens Stoltenberg in Brussels said the alliance had agreed to withdraw its roughly 7,000 forces from Afghanistan, matching Biden's decision to begin a final pullout by May 1.

The U.S. cannot continue to pour resources into an intractable war and expect different results, Biden said.

The drawdown would begin rather than conclude by May 1, which has been the deadline for full withdrawal under a peace agreement the Trump administration reached with the Taliban last year.

"It is time to end America's longest war," Biden said, but he added that the U.S. will "not conduct a hasty rush to the exit."

"We cannot continue the cycle of extending or expanding our military presence in Afghanistan hoping to create the ideal conditions for our withdrawal, expecting a different result," said Biden, who delivered his address from the White House Treaty Room, the same location where President George W. Bush announced the start of the war. "I am now the fourth United States president to preside over an American troop presence in Afghanistan. Two Republicans. Two Democrats. I will not pass this responsibility to a fifth."

Biden's announcement, which he followed with a visit to Arlington National Cemetery, marks perhaps the most significant foreign policy decision in the early going of his presidency.

He's long been skeptical about the U.S. presence in Afghanistan. As Barack Obama's vice-president, Biden was a lonely voice in the administration who advised the 44th president to tilt towards a smaller counterterrorism role in the country while military advisers were urging a troop buildup to counter Taliban gains. Biden has also made clear he wants to recalibrate U.S. foreign policy to face bigger challenges posed by China and Russia.

Withdrawing all U.S. troops comes with clear risks. It could boost the Taliban's effort to claw back power and undo gains toward democracy and women's rights made over the past two decades. It also opens Biden to criticism, mostly Republicans and some Democrats, even though former President Donald Trump had also wanted a full withdrawal.

"This administration has decided to abandon U.S. efforts in Afghanistan which have helped keep radical Islamic terrorism in check," said Senate Republican leader Mitch McConnell. "And bizarrely, they have decided to do so by September 11th."

While Biden's decision keeps U.S. forces in Afghanistan four months longer than initially planned, it sets a firm end to two decades of war that killed more than 2,200 U.S. troops, wounded 20,000, and cost as much as $1 trillion.

Biden spoke with Afghanistan President Ashraf Ghani on Wednesday ahead of his speech. The White House said in a statement that Biden told Ghani the United States would continue to support the Afghan people through development, humanitarian and security assistance.

"The Islamic Republic of Afghanistan respects the U.S. decision, and we will work with our U.S. partners to ensure a smooth transition," Ghani said in a Twitter posting.

Biden spoke, too, with former President Bush ahead of announcing his decision. He also spoke with allies, military leaders, lawmakers and Vice-President Kamala Harris to help make his decision, according to the White House.

He emphasized that his administration will continue to support peace talks between the Afghan government and the Taliban and assist international efforts to train the Afghan military.

Biden noted that the "forever war" has led to service members who weren't even alive at the time of the Sept. 11 attacks serving, as well as young troops following in the steps of their mothers and fathers in deploying to Afghanistan.

"The war in Afghanistan was never meant to be a multigenerational undertaking," Biden said.

Obama, who had hoped but ultimately failed to end the war during his time in office, said in a statement that he supported Biden's decision, that "it is time to recognize that we have accomplished all that we can militarily, and that it's time to bring our remaining troops home."

Following his speech, Biden visited Arlington National Cemetery to honour those who died in recent American conflicts. After paying his respects, Biden told reporters it was "absolutely clear" to him that ending the war was the right decision. Biden, in his speech and during his visit to the hallowed cemetery, reflected on his own late son Beau Biden's service. The president's son, who died of cancer in 2015, had deployed to Iraq with the Delaware Army National Guard.

"I'm always amazed that generation after generation, women and men give their lives to this country," Biden said. "It means I have trouble these days showing up to this cemetery and not thinking about my son."

CIA Director William Burns acknowledged at a hearing Wednesday that America's ability to contain the terrorist threat from Afghanistan has benefited from the military presence there, and that when that presence is withdrawn, "the U.S. government's ability to collect and act on threats will diminish."

"That's simply a fact," Burns said. "It is also a fact, however, that after withdrawal, whenever that time comes, the CIA and all of our partners in the U.S. government will retain a suite of capabilities, some of it remaining in place, some of them that we will generate, that can help us to anticipate and contest any rebuilding effort."

A senior administration official said the September withdrawal date was an absolute deadline that won't be affected by security conditions in Afghanistan.

The long conflict has largely crippled al-Qaida and led to the death of Osama bin Laden, the architect of the Sept. 11 attacks. But an American withdrawal also risks many of the gains made in democracy, women's rights and governance, while ensuring that the Taliban, who provided al-Qaida's haven, remain strong and in control of large swaths of the country.

As Biden announced his decision, his top national security aides -- Secretary of State Antony Blinken and Defence Secretary Lloyd Austin -- were consulting in Brussels to co-ordinate NATO's withdrawal from Afghanistan with the planned pullout of American troops.

Stoltenberg, the NATO chief, said the alliance's full withdrawal would be completed "in months" but did not mention the 20th anniversary of the Sept. 11 terrorist attacks.

"We went into Afghanistan together, we have adjusted our posture together and we are united in leaving together," he said.

------

Lee reported from Brussels. Associated Press writers Eric Tucker, Alexandra Jaffe, Zeke Miller and Darlene Superville contributed reporting.