Joe Biden's pullout from Afghanistan has stunned with its speed, but Washington already decided four years ago that it was fed up with "forever wars" and turned its attention to traditional great power competition with China and Russia.
Fighting stateless terror groups like Al-Qaeda and Islamic State consumed the US security establishment, and trillions of dollars, since the September 11, 2001 attacks.
Biden predecessor Donald Trump came to office in 2017 promising to quit Afghanistan, calling the war there a "mess" and a "waste."
The conflicts there and in Iraq had come to be characterized by unending troop deployments, persistent levels of violence, and no ability to conclusively defeat the enemy.
By 2020 Trump had overcome resistance and laid the ground for pullouts, leaving only 2,500 troops in each country by the time he stepped down in January. Biden accepted that trajectory, announcing Thursday that US military involvement in Afghanistan would conclude by August 31.
"We are ending America's longest war," he said. "The United States cannot afford to remain tethered to policies created to respond to a world as it was 20 years ago."
- Challenge from Putin and Xi -
The 9/11 attacks blindsided the US security establishment, forcing a whole-of-government refocus and the launching of the "War on Terror."
The US and NATO allies invaded Afghanistan to oust the Taliban government, which had protected Al-Qaeda.
And then-president George W. Bush took advantage to also invade Iraq to overthrow strongman Saddam Hussein, hoping to remake the Middle East and snuff out a broader threat.
The initial assaults largely succeeded quickly, with Al-Qaeda fractured and on the run in Afghanistan, and Saddam deposed and captured in Iraq.
But in both cases the United States and allies remained on the ground, hoping to rebuild each country, and unable to pull out without risking a return to the pre-9/11 situation.
Then, starting in 2013, US security leaders rebooted their views when new Chinese President Xi Jinping began aggressively expanding his country's military.
Seeking to counter and surpass US military strength, China began building armed bases on disputed islets in the South China Sea, added a base in Djibouti and planned other bases around Asia and the Middle East.
Meanwhile in 2014 Russian President Vladimir Putin sent forces to seize Ukraine's Crimea and supported an insurgency in eastern Ukraine.
Two years later Moscow mustered an aggressive campaign to influence the US presidential elections.
During the same period, young North Korean leader Kim Jong Un embarked on an ambitious plan to develop nuclear weapons with missiles that could threaten the United States.
Trump's 2017 National Security Strategy confirmed the pivot.
"China and Russia challenge American power, influence, and interests, attempting to erode American security and prosperity," it said.
"They are determined to make economies less free and less fair, to grow their militaries, and to control information and data to repress their societies and expand their influence."
- New flashpoints: Ukraine and Taiwan -
Reminiscent of the Cold War, the reorientation meant a Pentagon push to expand its navy, build stronger long-range bomber and submarine strike forces, and update its nuclear weapons.
It has also meant countering the Chinese and Russian challenge in new domains, with the Pentagon establishing both Space Command and Cyber Command.
The new priorities took root under Trump, and Biden confirmed them in March in his own national security policy.
"The distribution of power across the world is changing, creating new threats. China, in particular, has rapidly become more assertive," it said.
"Both Beijing and Moscow have invested heavily in efforts meant to check US strengths and prevent us from defending our interests and allies around the world."
Instead of Afghanistan and Iraq-Syria, Ukraine and Taiwan are the new flashpoints.
Both have recently received more and more advanced US weaponry to deter, respectively, Russia and China.
The Pentagon created a new office focused on China. US naval vessels regularly sail the waters around Taiwan and in the South China Sea, implicitly challenging China's territorial claims.
As for Russia, Biden has sought to strengthen bonds with NATO allies.
Over the past week, too, US vessels took part in exercises in the Black Sea where Russian forces were conducting their own manuevers.
Counter-terrorism doesn't end with the Afghanistan pullout, the Pentagon stresses.
But it is turning more remote-directed -- using air and missile strikes from remote bases and vessels to act in Afghanistan where Al-Qaeda still operates.
"We are repositioning our resources and adapting our counterterrorism posture to meet the threats where they are now," Biden said.