WASHINGTON -- Pakistan told the United States that it would reopen NATO's supply routes into neighboring Afghanistan after Secretary of State Hillary Rodham Clinton said she was sorry for the deaths of two dozen Pakistani soldiers in American airstrikes in November, officials from the two countries said Tuesday.
The agreement ended a bitter seven-month stalemate that threatened to jeopardize counterterrorism cooperation, complicated the American troop withdrawal from Afghanistan and cost the United States more than $1 billion in extra shipping fees as a result of having to use an alternative route through Central Asia.
Mrs. Clinton said that in a telephone call on Tuesday morning to Pakistan's foreign minister, Hina Rabbani Khar, they had agreed that both sides made mistakes that led to the fatal airstrikes.
"We are sorry for the losses suffered by the Pakistani military," Mrs. Clinton said in a statement that the State Department issued but that officials said had been coordinated with her Pakistani counterpart. "We are committed to working closely with Pakistan and Afghanistan to prevent this from ever happening again."
The accord came together on Monday in Islamabad after weeks of behind-the-scenes phone calls, e-mails and meetings between one of Mrs. Clinton's deputies, Thomas R. Nides, and a top Pakistani diplomat, American and Pakistani officials said. The agreement reflected a growing realization by Pakistani officials that they had overplayed their hand, misjudging NATO's resolve, and a recognition on both sides that the impasse risked transforming an often rocky relationship into a permanently toxic one at a critically inopportune time.
Mrs. Clinton and her top aides, working closely with senior White House and Pentagon officials, carefully calibrated what she would say in her phone call to Ms. Khar to avoid an explicit mention of what one top State Department official called "the A-word" -- "apology." Instead, Mrs. Clinton opted for the softer "sorry" to meet Pakistan's longstanding demand for a more formal apology for the airstrikes.
Still, the deal carries risks for both governments. Critics of Pakistan's weak civilian leadership assailed the accord as a sellout to the United States, and it offers potential fodder for Republicans who contend that President Obama says "sorry" too readily.
"The apology will lower the temperature on U.S.-Pakistan relations," said Shamila N. Chaudhary, a South Asia analyst at the Eurasia Group who served as the director for Pakistan and Afghanistan at the National Security Council. "However, relations are not on the mend. They remain very much broken and will remain so unless the two countries resolve broader policy differences on Afghanistan."
As part of the agreement, Pakistan dropped its insistence on a higher transit fee for each truck carrying NATO's nonlethal supplies from Pakistan into Afghanistan, after initially demanding as much as $5,000 for each truck.
In the end, Pakistan agreed to keep the fee at the current rate, $250. In return, the administration will ask Congress to reimburse Pakistan about $1.2 billion for costs incurred by 150,000 Pakistani troops carrying out counterinsurgency operations along the border with Afghanistan, a senior American official said.
The November airstrikes, which hit in Pakistani territory in response to reports of militant activity in the area, killed 24 soldiers. In response, Pakistan closed the supply lines and worsened relations already badly frayed by the shooting death of two Pakistanis by a Central Intelligence Agency security contractor and by the Navy SEAL raid that killed Osama bin Laden.
Soon after the strikes, the White House decided that Mr. Obama would not offer formal condolences to Pakistan, overruling State Department officials who argued for such a show of remorse to help salvage relations. Pentagon officials also balked, saying that the statements of regrets and condolences from other American officials had been sufficient and that an apology would absolve Pakistan's military of any blame in the accident.
Even those in the administration who advocated apologizing did so almost exclusively for practical reasons, such as getting Pakistan on board with the stalled Afghan peace process, officials familiar with the discussions said.
Pakistan, at times, seemingly undermined its own effort to obtain an expression of contrition. The administration was seriously weighing an apology when Afghan insurgents hit multiple targets in simultaneous attacks on Kabul in April, officials said. American military officials quickly linked the attacks to the Haqqani network, a Taliban faction that operates out of Pakistan's tribal areas on the Afghan border. The apology would wait.
In May, days before a NATO summit meeting in Chicago, President Asif Ali Zardari of Pakistan earned a last-minute invitation to the talks when it looked as if a deal to reopen the supply lines might be at hand. But no deal materialized.
After that failure, Mr. Nides and Pakistan's finance minister, Abdul Hafeez Shaikh, were designated by their governments to begin negotiating. Mr. Nides, a former executive at Morgan Stanley, and Mr. Shaikh hit it off, and began swapping e-mails and phone calls to work out a political deal.
At the same time, according to officials, Gen. Ashfaq Parvez Kayani, the Pakistani army chief of staff, was pressing his government to resolve the issue, which had put Pakistan at odds with the more than 40 countries with troops in Afghanistan whose supplies were affected.
Pakistani officials said they had misjudged NATO's ability to adapt to the closing and use an alternative route through Central Asia. That rerouting carried a high price: Defense Secretary Leon E. Panetta said it was costing up to an extra $100 million a month.
Last weekend, Mrs. Clinton telephoned her congratulations to Pakistan's new prime minister, Raja Pervez Ashraf. But it was Mrs. Clinton's increasingly cordial relationship with the young Pakistani foreign minister, Ms. Khar, 34, that paid dividends in resolving the dispute, American officials said.
Several weeks ago, Mrs. Clinton began working on drafts of the statement she released on Tuesday, and at one point began discussing the language with Ms. Khar, a person with knowledge about the process said. "This was jointly done," said the person, who, like half a dozen other officials from both countries, spoke on condition of anonymity because of diplomatic protocols.
Also over the weekend, Mr. Nides arrived in Islamabad, joined by Gen. John R. Allen, the American commander of NATO forces in Afghanistan, and James N. Miller, the Pentagon's top policy official, for meetings with their Pakistani counterparts. On Monday, they put the finishing touches on the agreement. "The Nides visit this past weekend pushed it over the line," one senior American official said.
In Pakistan on Tuesday, the decision to reopen the supply routes was met with a general sense of befuddlement and muted criticism that the government had given up a much-trumpeted increase in transit fees for NATO trucks.
But government officials were at pains to claim that the accord had never hinged on higher fees. "I am glad that this breakthrough is not part of any transaction," said Sherry Rehman, Pakistan's ambassador to the United States. "We are playing our role as responsible global partner in stabilizing the region."
Still, opposition politicians criticized the move and demanded more of an explanation from the Pakistani government and military.
"Now government should let the people know about the terms and conditions for reopening the NATO supply lines. What were the demands?" said Shah Mehmood Qureshi, a former foreign minister and leader of Pakistan Tehreek-e-Insaf, a popular opposition political party led by the former cricket star Imran Khan.
Enver Baig, an opposition politician belonging to the Pakistan Muslim League-Nawaz, referring to the Americans, complained: "They did not apologize. They said 'sorry.' "
Salman Masood contributed reporting from Islamabad, Pakistan, and Matthew Rosenberg from Kabul, Afghanistan.
This article originally appeared in The New York Times.