Updated

This week's NATO summit was long planned as a celebration to mark the end of combat in Afghanistan and the coalition forces' shift to a largely advisory role. But the still-unsettled Afghan election has complicated the event, casting doubt on the transition and leaving the door open for all allied troops to be forced out at year's end.

As international leaders gather here, including President Obama, there is a nagging uncertainty about whether the Afghans will be able to put a new president in place and soon sign the security agreement that the U.S. and allies need to keep troops in the country into next year.

On Thursday, NATO Secretary-General Anders Fogh Rasmussen warned that time is short for Afghan leaders to resolve their presidential election and sign the agreement. He said allied nations stand ready to commit assistance and troops, and will reach their $4.1 billion goal for funding Afghan security forces, but some final decisions can't be made until the political stalemate is over.

Without the agreement, Rasmussen said, "there can be no mission. Although our military commanders have shown great flexibility in their planning, time is short. The sooner the legal framework is in place, the better."

The April 6 voting to elect a successor to President Hamid Karzai resulted in a runoff between the two candidates. Both have pulled their observers out of a ballot audit meant to determine the winner, and the final results of the audit are expected sometime next week.

The U.S. plans to withdraw all but roughly 10,000 troops by the end of this year, to advise the Afghans and conduct some counterterror missions. That number would be cut in half by the end of 2015. The U.S. would leave only about 1,000 in a security office after the end of 2016.

During the summit session, NATO leaders reaffirmed their commitment to the Afghanistan mission, and there was a short ceremony honoring troops that have died in the 13-year conflict.

Because the presidential election is not final, Afghan Defense Minister Gen. Bismullah Khan Mohammadi, represented his country at the summit. Outgoing President Hamid Karzai and the two candidates did not attend.

Instead, Rasmussen said, the two candidates, former Foreign Minister Abdullah Abdullah and ex-Finance Minister Ashraf Ghani Ahmadzai, sent a message to NATO, indicating "that they will do all they can to reach a political agreement."

In a separate private meeting Thursday on the sidelines of the summit, Mohammadi reassured Defense Secretary Chuck Hagel that both presidential candidates continue to support the security agreement and that "solid progress toward the completion of the election audit" is being made, said Rear Adm. John Kirby, the Pentagon press secretary.

Senior U.S. military leaders are also optimistic despite the delays. They believe that the Afghans will resolve the election stand-off, and the winner will sign the security agreement.

But last week, Marine Gen. Joseph Dunford, who was stepping down as the top U.S. commander in Afghanistan, said that the election stalemate this summer hurt progress in training the country's military.

Speaking as he was leaving Afghanistan, Dunford said resolving the political chaos will be key to that military's success in 2015.

Just prior to the summit's start, the Taliban in a dawn attack Thursday struck a government compound in eastern Afghanistan, killing at least 12 people.

In a stark message to leaders at the NATO summit, the group said that the exit of all foreign combat troops at the end of the year is proof that "no nation is able to subdue a free nation, especially a nation proud and free such as Afghanistan."

Rasmussen said NATO is in the process of identifying forces for the noncombat advisory mission, but some other nations haven't made firm commitments because of the ongoing election uncertainty.

Once the politics are settled, he said he is confident nations will fully fill the training mission requirements.

Under an agreement reached at the NATO summit in Chicago in 2012, allies pledged to fund an Afghan force of 230,000 after 2014.  It would cost the allies about $4.1 billion annually.