After almost a year of delays, U.S. and Afghan officials signed a bilateral security agreement Tuesday that will allow nearly 10,000 U.S. troops to stay in Afghanistan after the end of the year.

The deal "will enable American and coalition troops to continue to help strengthen Afghan forces, counter terrorist threats, and advance regional security," said Defense Secretary Chuck Hagel in a statement. That includes, he added, working to "build an enduring strategic partnership" as the official U.S. combat mission winds down.

So where does the U.S. go from here?

Not all U.S. troops are coming home. Approximately 9,800 soldiers are expected to stay in Afghanistan after the end of 2014, down from about 38,000 at the beginning of the year. By the end of 2015, that number will be cut in half to about 4,900, and soldiers will be located in two areas: the capital city of Kabul and Bagram Air Base, roughly an hour north of the capital.

Most soldiers will be out of the country by the end of 2016. After 2016, the United States will draw down its troop levels to "normal embassy presence in Kabul, with a security assistance component," President Obama said earlier this year. That means at the start of 2017, there will be approximately 1,000 troops in the country, compared with the peak presence of more than 100,000 troops in Afghanistan in 2010 and 2011.

That means the U.S. war budget—in theory—should decrease. As the U.S. draws down in Afghanistan, the overseas contingency operations fund is expected to decline significantly. Commonly referred to as the war budget—and not subject to congressional budget caps—the administration is asking for $58.6 billion in fiscal 2015 compared with the current $85 billion budget.

But that request was made before the United States launched airstrikes against ISIS militants in Iraq and Syria. The Pentagon estimates that it is spending between $7 million to $10 million per day in the fight against ISIS, all from the war budget. And the cost of the fight against ISIS could range from $2.4 billion to $22 billion, depending on the frequency of airstrikes and level of ground troops, according to a study released Monday by the Center for Strategic and Budgetary Assessments, a D.C.-based think tank. Either way, top Pentagon officials told reporters last week that they're going to need more money from Congress.

U.S. aid to Afghanistan will also continue. The United States has allotted more than $104 billion to Afghanistan's reconstruction effort since fiscal 2002. And that funding won't dry up just because the U.S. military presence in the country is drawing down. John Sopko, the special inspector general for Afghanistan reconstruction, said earlier this month that U.S. efforts "will continue at a high tempo for some years to come if we want to keep the Afghan military and government afloat and protect our reconstruction successes."

That likely includes giving Afghanistan an additional $5 billion to $8 billion annually, he said, "for years to come."

Other countries will also keep troops in Afghanistan. Afghan officials are also expected to sign a status-of-forces agreement with NATO, ensuring that alliance troops stay in the country after 2014 to help train, assist, and advise.

It's unclear how many soldiers the alliance will keep in the country, but it's certain to be less than the U.S. commitment. Troop levels "are currently being finalized," a NATO official said. "The process to generate the forces we need is well underway. Several Allies and Partners intend to make significant contributions. We are confident that we will have all necessary resources to carry out that mission."