US Secretary of State John Kerry en route to ISAF headquarters after arriving on an unannounced visit to Kabul, Friday. Kerry held urgent talks with Afghan President Hamid Karzai as a deadline looms for completing a security deal that would allow American troops to remain in Afghanistan after the end of the NATO-led military mission next year.

Washington wants to keep 5,000 to 10,000 US troops in Afghanistan beyond the Dec. 31, 2014, end of the NATO-led combat mission. Their purpose would be to train Afghan troops as well as to carry out counterterrorism and counterinsurgency missions against Al Qaeda.

Without such an agreement, all US troops would pull out by the end of 2014 – the so-called “zero option.” (Of the 87,000 NATO troops in Afghanistan now, 52,000 are Americans.)

President Obama told the Associated Press in an interview last week that he would consider keeping some American forces on the ground after the NATO combat mission formally ends next year, but acknowledged that doing so would require an agreement.

Obama suggested that if no agreement can be reached, he would be comfortable with a full pullout of US troops. This likely would lead to an early pullout of troops by other NATO countries, and it could threaten international aid.

The talks over the pact – a “bilateral security agreement” – have stalled over two points.

One is a US request to run independent counterterrorism missions on Afghan territory, which have long infuriated President Karzai. The Afghans instead want the United States to pass on information and let them handle the action.

The second sticking point is a US refusal to guarantee protection from foreign forces, which could lead to offensive action against another ally, neighboring Pakistan.

Karzai – with whom the US has had a rocky relationship over the years – recently complained about violation of Afghan sovereignty as well as the war’s impact on the Afghan people. His personal relationship with Secretary Kerry has been relatively cordial, however, and US officials are hopeful that this will help get the Bilateral Security Agreement talks moving again. During his years as Senate Foreign Relations Committee chairman, Kerry made several trips to Afghanistan.

In his talks with officials in Kabul Friday, Kerry was joined by US Ambassador to Afghanistan James Cunningham and Gen. Joseph Dunford, the top US general to Afghanistan.

"This is really about us building momentum for the negotiators and helping establish conditions for success of the negotiations going forward," a State Department official told reporters traveling with Kerry.

But another US official in Kerry’s party emphasized that "the ball remains in the Afghans' court.”

“Time is of the essence, the longer it goes, the harder it is to plan," this official said.

Daniel Markey, a senior fellow at the Council on Foreign Relations and author of the forthcoming book "No Exit from Pakistan," says that while the remaining issues are few in number, their importance could hinder chances for a deal.

"These sticking points, even if the differences have been narrowed, are sticky enough that there is some serious question as to whether this will happen before President Karzai leaves office," Mr. Markey told CNN. (Karzai may not run for reelection in Afghanistan’s presidential election next year.)

"And the lack of an agreement will be harmful to the potential legacy of a stable and smooth transition," Markey added. "There are so many other reasons to be worried about Afghanistan: the economy, the election and the lack of progress in dealing with reconciliation with the Taliban. This is one more thing that doesn't need to be added to the mix."

The US is mindful of its experience in Iraq, when the failure to achieve such a deal led to the pullout of US troops in 2011. In the Taliban, Afghanistan faces a stronger insurgency than did Iraq, when it came time to reduce the US presence there. Meanwhile, the upcoming election in Afghanistan could hinder progress toward a US-Afghan security agreement, as questions of Afghan sovereignty become increasingly politicized.

“As the Afghan political establishment shifts into election mode, it’s going to be more difficult for them to focus on getting to a resolution of these issues, so we’d like to bring them to a close before we get to that point,” one of the State Department officials traveling with Kerry said Friday.