Secretary of State John Kerry traveled to Afghanistan on Friday for an unannounced visit, weeks before U.S. and Afghan negotiators must finalize a post-war security deal.

Kerry will meet with Afghan President Hamid Karzai, the State Department spokesperson Jen Psaki announced.

The meeting comes as talks on a security deal governing the role of American troops after 2014 remain deadlocked ahead of an Oct. 31 deadline.

The NATO-led military mission will end next year, but the Obama administration hopes to secure a post-war plan that would leave some American troops in Afghanistan to assist local forces against the Taliban.

Karzai though has demanded U.S. assurances that they will protect his country against foreign intervention and bar American forces from carrying out special operations missions, according to reports.

If no deal is reached, all U.S. forces must leave Afghanistan at the end of 2014. Military experts say that a failure to hammer out a deal could also complicate efforts to withdraw NATO forces during the last year of the mission.

President Obama in an interview with the AP last week said that he was interested in a “consider a train-and-advise mission that would extend beyond 2014 -- greatly reduced from what we're doing now.”

Asked if he was comfortable with the “zero option,” the withdrawal of all American military personnel from Afghanistan, Obama said it is in “both the interest of the Afghans and the United States that we are in a position to continue to help their military consolidate security in their country.”

But he added, that if no deal is reached, “we will continue to make sure that all the gains we've made in going after al Qaeda we accomplish, even if we don't have any U.S. military on Afghan soil.”

Brian Hughes contributed.