WARSAW (Reuters) - NATO allies agreed on Saturday to help fund Afghan security forces to the tune of around $1 billion annually over the next three years, despite public fatigue in Western countries about their involvement in the long-running conflict.

U.S. President Barack Obama (L) shakes hands with Afghanistan's President Ashraf Ghani next to NATO Secretary General Jens Stoltenberg (R) and Afghanistan's Chief Executive Abdullah Abdullah at the NATO Summit in Warsaw, Poland July 9, 2016. REUTERS/Kacper Pempel

Fifteen years since the United States invaded to topple the Taliban rulers who had harbored al Qaeda militants behind attacks on the United States, the West remains entangled in a costly effort to stabilize a country facing resurgent rebels.

U.S. President Barack Obama said completely withdrawing from Afghanistan risked seeing the country collapse and then having to send American troops back in again to deal with a new threat.

“We have an option of ... pulling out and potentially then seeing a country crumble under the strains of continued terrorist activity or insurgencies,” Obama told a news conference at the end of a NATO summit in Warsaw.

He defended his decision, along with other NATO allies, to reverse plans to sharply reduce troops levels, saying Afghan forces still needed training, funding and support.

“The Afghans are fighting. They are much more capable now than they were when I came into office, but they still need support because it is a really tough territory and it is a really poor country,” Obama said.

NATO Secretary-General Jens Stoltenberg said he had won almost $3 billion in commitments from allies to help the United States pay for the Afghan military until 2020, which now has ground forces but still needs to develop an air force.

A senior U.S. official said, on condition of anonymity, that the allies had made pledges that put them at more than 90 percent of the funding levels agreed to at a 2012 NATO summit in Chicago.

The United States has been keen to secure the target of one billion dollars annually from other countries to support more than 350,000 Afghan security forces as it draws down its own military presence in the country.

The Pentagon has budgeted $3.45 billion in annual U.S. funds to pay for the Afghan forces, with the Kabul government providing an additional sum of around $420 million, for a total yearly budget of nearly $5 billion.

For the United States, the stakes are high as it seeks to prevent Afghanistan from once again becoming a haven for groups hostile to the West, including al Qaeda and Islamic State, also known as ISIL, which has made some inroads in the country.

“We know there are al Qaeda and ISIL components in Afghanistan and if we fail there, we know that it’ll be a safe haven for those,” U.S. Army General Curtis Scaparrotti, the top NATO commander, told reporters on the sidelines of the summit.

Slideshow ( 27 images )

RESOLUTE SUPPORT

Obama announced this week that the United States was shelving its plans to cut the U.S. force in Afghanistan nearly in half by the end of 2016, opting instead to keep 8,400 troops there till the close of his presidency next January. That still implies a 1,400-troop reduction.

There are currently about 13,000 U.S. and international troops serving in the NATO mission, called Resolute Support, in Afghanistan, with Germany, Turkey and Italy as the biggest non-U.S contributors. Their role is to train the Afghan forces.

The United States has additional troops in Afghanistan focusing on counter terrorism operations.

Stoltenberg said it was too early to say what troop levels the NATO allies would maintain in 2017 and said those decisions would be made in the autumn.

A senior U.S. official said the non-U.S. allies would collectively contribute about the same number of troops to the mission as they do now, although individual countries’ numbers may vary. The size of the NATO mission is on track to be more than 12,000 troops after the adjustments, U.S. officials said.

Afghanistan faces a number of crises, including a faltering economy, a government weakened by infighting between rivals and endemic corruption. Both President Ashraf Ghani and Chief Executive Abdullah Abdullah, Ghani’s runner-up in the 2014 presidential election, attended the NATO summit.

A U.S. official said the United States and its allies were encouraged by the fact that some cabinet-level appointments had recently moved through the Afghan parliament, that the government was doing better in collecting tax revenues and that Ghani had diligently pursued anti-corruption measures.

“We expect they (Afghan leaders) will step up their efforts to fight corruption and to implement reforms,” Stoltenberg said.