ISLAMABAD, Pakistan -- Secretary of State John Kerry said on Thursday that he expected the United States and Afghanistan to complete a security agreement that would allow American forces to stay in Afghanistan after 2014.
"I am personally confident that we will have an agreement," Mr. Kerry said during a visit here.
Mr. Kerry's comments appeared intended to reassure the Afghanistan and Pakistan governments that the United States was not abandoning the region.
Several prominent lawmakers in the United States have criticized the White House for failing to say how many troops it plans to keep in Afghanistan after 2014 and even stating that the White House has been considering pulling out all forces from there -- the so-called "zero option." That approach, they have argued, has backfired by heightening insecurity in Afghanistan.
Mr. Kerry declined to say what issues remained to be settled in the talks over the Bilateral Security Agreement, as the accord that is being worked out by the United States and Afghanistan is known.
Nor did he indicate when President Obama would decide how many troops should remain in Afghanistan. But Mr. Kerry said he expected that American forces would remain, along with troops from allied countries, to train Afghanistan's forces and carry out commando raids against terrorist groups as it takes over security of the country from coalition troops.
"The United States is drawing down, not withdrawing," Mr. Kerry said. "So I am very hopeful that this is a transition, not an ending."
Mr. Kerry's visit here, which was not announced in advance, was the first high-level visit since Pakistan's new prime minister, Nawaz Sharif, took office.
Mr. Sharif's election was the first time in Pakistan's tumultuous history that a civilian Pakistani government has followed another civilian government that had served its entire term -- a development Mr. Kerry portrayed as a march toward democracy.
The United States's relationship with Pakistan has been a difficult one. Early in the Obama administration, it appeared to be one of bold expectations and talk of a full-blown "strategic partnership."
But the relationship was severely strained by Pakistan's failure to crack down on the safe havens that the Taliban-affiliated Haqqani network and other military groups used to mount attacks inside Afghanistan.
Relations were also strained by both the United States's raid in 2011 that killed Osama bin Laden in his compound in Abbottabad, Pakistan, an operation that was conducted without advance knowledge of the Pakistanis, and a NATO airstrike that year that killed 24 Pakistani troops.
The drone attacks that the United States has carried out against militants in Pakistan, which American officials say have been necessary because of the safe havens, have also been deeply unpopular here.
A senior official on Mr. Kerry's trip described 2010 and 2011 as a "very difficult period," but said relations had improved recently.
"Starting last summer, I think we entered into a very constructive period," he said. "We really tried to have much more sober expectations, be more realistic, talk about the issues of most strategic interest to us and Pakistan."
Mr. Kerry's trip was seen as an effort to improve relations with the new civilian government here as it seeks to reclaim authority from the military.
Mr. Kerry met Thursday with Mr. Sharif, who delayed a trip to Mecca to see Mr. Kerry, and with Sartaj Aziz, the prime minister's foreign affairs adviser. Mr. Kerry was scheduled to meet Thursday night with Ashfaq Parvez Kayani, Pakistan's powerful army chief.
Stressing that the two sides wanted improved relations, Mr. Kerry noted that he had invited Mr. Sharif to come to Washington and meet with Mr. Obama.
"What was important today was that there was a determination by the United States and by Pakistan to move this relationship to the full partnership that it ought to be, and to find the ways to deal with individual issues that have been irritants over the course of the past years," Mr. Kerry said.
Still, amid the talk of making a fresh start, there were signs of strain. In a joint news conference, Mr. Aziz said that his government wanted the drone attacks to stop.
"Drone attacks are counterproductive to our relationship," he said. "We are asking for stopping."
Citing Mr. Obama's major speech on the issue, Mr. Kerry made the case for continuing drone strikes on a selective basis. It is the terrorists who are the target of the attacks, Mr. Kerry said, and it was they who had violated Pakistan's sovereignty.
But both sides refrained from heated words in public and agreed to discuss this in future talks.
In an effort to avoid inflaming public sentiment, the Obama administration had cut back on the number of drone attacks in Pakistan.
According to the New America Foundation, there have been 16 drone strikes in Pakistan this year, compared with 48 in 2012, 73 in 2011 and 122 in 2010.
This article originally appeared in The New York Times.