Secretary of State John Kerry looks out the window of a helicopter en route to the ISAF headquarters in Kabul on Oct. 11, 2013. Kerry arrived in Afghanistan on Friday for talks with Afghan President Hamid Karzai . (Jacquelyn Martin/Pool via Reuters)

With negotiations over terms for some U.S. forces to remain in Afghanistan after 2014 at an impasse, Secretary of State John F. Kerry made an unannounced visit to the Afghan capital Friday to bargain directly with Afghan President Hamid Karzai.

Kerry, who has a long relationship with the mercurial Afghan leader, is trying to help bridge the last sticking points that have prevented the countries from reaching a deal, State Department officials traveling with Kerry said.

Karzai made friendly small talk with Kerry at the start of a meeting at his palace. The two then met for about three hours, including dinner, U.S. officials said afterward. They also went for a 10-minute walk alone on the Afghan palace grounds.

The mood appeared relaxed, and neither Kerry nor Karzai said anything about the substance of the coming discussion when reporters were initially in the room.

U.S. officials described the talks as candid but not shrill and said differences were narrowed. They would not provide details and said the two men would meet again Saturday.

Talks are expected to continue after Kerry’s visit, but he will stress the need to secure a deal by the end of the month, officials said.

“This is not about Secretary Kerry coming in to close a deal,” said one official, who spoke on the condition of anonymity to preview the U.S. arguments.

Talks on a security agreement are stalled over long-standing Afghan demands for greater control and access to U.S. intelligence, and U.S. insistence that remaining forces not be subject to Afghan law.

The Bilateral Security Agreement (BSA) is supposed to assure Afghans of an ongoing U.S. commitment and to protect the estimated 5,000 to 10,000 U.S. forces expected to carry out training and counterterrorism missions after the NATO-led international mission ends in 2014.

Karzai has recently denounced U.S. demands as unreasonable and appeared ready to walk out on talks. Kerry is making a last-ditch appeal to Karzai, trying to convince him that the pact is in Afghanistan’s interests and that Karzai risks losing U.S. and NATO pledges of aid and cooperation if no deal is made.

Karzai has insisted he’s in no hurry to sign a security agreement with the United States, saying that perhaps his successor could resume negotiations next year, despite eagerness on the part of the United States to finish a pact this month.

“If the agreement doesn’t suit us, then, of course, they can leave,” Karzai said in an interview with the BBC this week. “The agreement has to suit Afghanistan’s interests and purposes. If it doesn’t suit us and if it doesn’t suit them, then naturally we will go separate ways.”

Karzai has said that two major sticking points hold up a deal: the lack of commitment from the United States to protect Afghanistan from Pakistan, and the U.S. interest in conducting unilateral operations in Afghanistan, which he rejects.

The latter point has become even more contentious in recent weeks, Afghan officials said, after the United States abducted a top Pakistani Taliban commander, Latif Mehsud, who was in the custody of Afghanistan’s National Directorate of Security (NDS).

In Washington on Friday, the State Department confirmed that “U.S. forces did capture . . . Mehsud in a military operation.” Department spokeswoman Marie Harf declined to provide details of the timing and circumstances of the operation.

Afghan officials said that what U.S. officials called a “military capture” was instead the forcible seizure of Mehsud from the custody of ostensible allies in the NDS. Karzai spokesman Aimal Faizi called the action a serious violation of Afghan sovereignty by U.S. forces.

Most influential Afghan officials have voiced support for an enduring U.S. military presence here. But those close to Karzai say he’s become increasingly concerned about how history will judge him for signing an agreement that could be seen as compromising the country’s sovereignty.

“We believe this is a very important agreement. . . . And the president has said we should not be in a hurry to sign it,” Faizi said in an interview this month. “If anything goes wrong, he will be held accountable by history.”

On the eve of Kerry’s visit, the Taliban released a statement saying: “NATO invading forces will also not reach their selfish goals by extending their mission for another year. Without a doubt, the losses of NATO and other foreigners will only increase here and their troops shall continue to live under our unrelenting strikes.”

President Obama and Karzai agreed months ago to try to complete a deal by Oct. 31, which another official called “preferable and doable.”

U.S. officials want the deal sealed so that 2014 can be spent planning for the post-
withdrawal period, after more than 12 years of war. The Obama administration is also concerned that if left hanging, the proposed deal will become an issue in Afghan elections planned for April.

Karen DeYoung contributed to this report.