After months of political bickering in Afghanistan, a new president has been sworn in, and a long-delayed security agreement has been signed. But, the new government faces severe economic problems and the threat of a resurgent Taliban.

The bilateral security agreement allows about 12,000 U.S. and NATO military personnel to continue training Afghan security forces.

Al-Qaida militants will also be targeted.

The deal was signed just a day after new Afghan President Ashraf Ghani was sworn in.

"As an independent country, and understanding of our national interests, we signed this agreement for stability, goodwill and prosperity of our people," he said.

But in the days following the pact, Taliban suicide bombers attacked Afghan army buses in Kabul, underscoring the fragile security.

“The security situation is bad and deteriorating, and I think now getting this new government and political stability is really important so that attention can now focus on improving the security situation," said analyst Andrew Wilder.

Analysts say the surge of Islamic State extremists in Syria and Iraq has the attention of Afghans.

They remember the 2003 U.S.-led invasion of Iraq that drew attention away from the conflict in Afghanistan.

In recent months Taliban fighters have made significant gains in Afghanistan.

The top U.S. commander in Afghanistan, Army General John Campbell, says Afghan security forces have suffered a recent spike in casualties during battles with insurgents. He told reporters Thursday that this year 7,000-9,000 Afghan troops have been wounded or killed, which is a bit higher than the totals so far for last year.

An increase in casualties was expected when Afghans officially assumed most of the fighting duties from NATO troops last year.

But, Campbell said that despite the casualties, the Afghan forces have been able to retake terrain captured by the Taliban, including in Helmand province where fighting has been intense in recent days.

Campell says some of the reports of Taliban successes have been dramatically exaggerated.

On the streets of Kabul, war-weary Afghans appear pleased foreign troops will stay.

"With the issues that Afghanistan is dealing with and the problems that people are facing from the economy, security, signing of this agreement between Afghanistan and America is a need," said Kabul resident Mohammad Akbar.

Much of Afghanistan’s future will depend on relations with its neighbors, especially Pakistan.

“The new government’s focus in Afghanistan will certainly be on enhancing and strengthening efforts to tackle and defeat terrorists much more effectively," said Janan Mosazai, Afghan ambassador to Pakistan.

Another daunting problem facing the new government is the economy, which analysts say is in serious trouble.

“What is really going to de-legitimize this government, I think, even more so than a flawed election process will be if it can’t pay salaries, can’t provide social services and the economy collapses," Andrew Wilder said.

Ghani has called on the Taliban to join peace talks. But he said the invitation should not be viewed as a sign of weakness.

Western nations are committed to help finance Afghan security forces through 2017.