President Trump took office after repeatedly promising to “beat the hell” out of the Islamic State and end the United States’ “endless wars.” But reality proved more complicated.

Although his administration oversaw the destruction of the Islamic State’s caliphate in Syria and a Special Operations raid that killed its leader, Abu Bakr al-Baghdadi, remnants of the group remain active in several countries.

Meanwhile, the U.S. military is still involved in Afghanistan, Iraq, Somalia, Syria, Yemen and other terrorism hot spots, after four years of Trump vowing to bring troops home.

President-elect Joe Biden is expected to face a similar landscape — and political pressure — as he takes over the White House.

In similar fashion to Trump, Biden has said it is time to “end the forever wars,” a catchall for 19 years of military operations launched in response to the September 2001 terrorist attacks. Thousands of U.S. troops — and many more civilians — have been killed since then, and trillions of dollars have been spent.

But Biden has indicated that ending the wars does not mean shutting down all counterterrorism operations abroad.

Although the “vast majority” of U.S. troops should come home, the United States must “narrowly define” and continue counterterrorism operations targeting al-Qaeda and the Islamic State, Biden wrote in Foreign Affairs magazine in the spring.

“We must maintain our focus on counterterrorism, around the world and at home, but staying entrenched in unwinnable conflicts drains our capacity to lead on other issues that require our attention, and it prevents us from rebuilding the other instruments of American power,” he wrote.

Early on, the Trump administration sought to reorient itself to prioritize “great power competition” with China and Russia above counterterrorism, and defense officials have said they wanted to make the shift “irreversible.”

But many of the longtime areas of conflict remain just as turbulent.

In Afghanistan, Biden must decide how to handle a delicate situation in which Trump signed a deal with the Taliban that calls for the removal of all U.S. troops by May. U.S. officials have said the agreement will be based on the conditions on the ground, but Trump nonetheless announced plans to cut the number of U.S. troops in Afghanistan to 2,500 by the end of his term, overriding concerns from senior U.S. commanders and former defense secretary Mark T. Esper.

In Iraq, the United States has the approval to keep a residual military force to train Iraqi forces and watch for any resurgence of the Islamic State, Gen. Mark Milley, chairman of the Joint Chiefs of Staff, said recently. But the situation is complicated by Iran, whose proxy forces repeatedly have launched rockets at American military positions. Iran also has vowed revenge for the U.S. killing in Baghdad of Qasem Soleimani, an Iranian general whom U.S. officials have blamed for the deaths of hundreds of Americans.

In Syria, the United States has kept about 1,000 service members deployed in what the Trump administration has said is an effort to protect oil fields from the Islamic State. But the situation is complex, with forces backing the Syrian regime, including Russians, also in the region.

U.S. Special Operations troops also remain in small numbers in Somalia, Yemen and western Africa.

Biden will have to assess risks, including threats to U.S. service members, when examining the future size of any mission, and whether to continue it, said David Maxwell, a retired Special Forces colonel and senior fellow at the Foundation for Defense of Democracies. Arrogance, Maxwell said, has on occasion led to decisions to leave U.S. units without enough support, allowing American fatalities.

“We must be asking: Does this mission fit into our national security strategy?” he said. “It’s a basic equation: Is the benefit [of] conducting this operation worth the cost of conducting it if it goes wrong?”

Michael K. Nagata, a retired Army general and former director of strategy for the National Counterterrorism Center, said the idea that the United States should focus less on counterterrorism and more on other issues is a “bankrupt premise.” For example, he said, less than three years after the U.S. military withdrew from Iraq, it launched operations there again against the Islamic State in 2014.

“I hear this riff all the time: ‘We’ve got to rebalance,’ as though this is somehow a zero-sum game,” said Nagata, now a distinguished senior fellow with the Middle East Institute. “I understand how attractive that idea is — it’s just completely unrealistic. It never works. It never lasts.”