ISLAMABAD — Pakistan and the United States signed a deal regulating the shipment of American troop supplies to and from Afghanistan on Tuesday, prompting Washington to agree to release over $1 billion in frozen military aid.

The developments represent the formal end to a crisis between the two countries that started in November when Pakistan closed its border to supplies meant for U.S. and other NATO troops in Afghanistan in retaliation for American airstrikes that killed 24 Pakistani soldiers.

Pakistan reopened the route running overland through its territory from the southern port of Karachi to the Afghan border in early July after the U.S. apologized for the deaths, which the Americans said were an accident. But it took several more weeks for the two sides to finalize the new agreement.

The deal codifies a largely informal arrangement that has allowed the international coalition to truck supplies through Pakistan over the past decade. Pakistan pushed for a written pact during months of negotiations, and it is expected to be extended to other NATO countries.

U.S. Charge d'Affaires Richard Hoagland, who signed the agreement for the U.S., called it a "concrete very positive step."

"Of course it's clear to our political leadership in both capitals ... that we have a number of other issues to work on," said Hoagland at the signing ceremony at the Pakistani Ministry of Defense in Rawalpindi.

The dispute over the supply route brought the already troubled U.S.-Pakistan relationship close to the breaking point, complicating American efforts to wrap up the war in Afghanistan. Pakistan is seen as key to getting the Taliban back to reconciliation talks aimed at ending the 11-year Afghan war.

The route through Pakistan will be vital to the scheduled withdrawal of U.S. troops from Afghanistan in 2014, one of the reasons the U.S. finally agreed to Islamabad's demand that it apologize for the deaths of the Pakistani soldiers. The U.S. had to compensate for the temporary closure by using a longer route into Afghanistan through Central Asia that cost an additional $100 million per month.

The new agreement applies to U.S. supplies that have not yet arrived in Pakistan, not the thousands of containers that have been stuck in the country for months and have slowly started moving across the border into Afghanistan. It also spells out the terms for the tens of thousands of containers that will be needed to pull U.S. equipment and supplies out of Afghanistan.

The resumption of supplies through Pakistan in the last few weeks has been slowed by bureaucratic delays, disputes over compensation and security concerns. One of the two crossings used to ship NATO supplies to Afghanistan has been closed for the past several days as officials work with the Pakistani military to come up with a plan to protect against Taliban attacks.

The new deal prohibits the U.S. from shipping weapons by land through Pakistan — as demanded by the country's parliament — unless intended for Afghan national security forces, according to a copy of the agreement obtained by The Associated Press.

Following the deaths of the 24 soldiers, the parliament had also demanded a ban on weapons shipped through Pakistani airspace to Afghanistan and an end to U.S. drone attacks in Pakistan. But there is no indication that the U.S. has complied with these conditions.

Pakistan insisted on transit fees as high as $5,000 per truck during the negotiations to reopen the supply line but eventually agreed to the existing charge of $250 — although this figure is not clearly spelled out in the agreement.

To sweeten the deal, the U.S. agreed to spend hundreds of thousands of dollars on Pakistan's roads, which the government says have suffered significant damage from heavily loaded NATO trucks. But this promise does not appear in the new agreement.

The longstanding informal agreement to ship NATO supplies through Pakistan was struck with the government of former President Pervez Musharraf, who stepped down in 2008. The parliament demanded in a recent resolution that any future agreements with the U.S. be put in writing.

Pakistan waited months to reopen the supply line partly because of concern over a backlash in the country, where anti-American sentiment is rampant. But the government was keen to unblock American aid that had been frozen as the relationship between the two countries declined.

Hoagland, the U.S. charge d'affaires, said Washington would release $1.1 billion in military aid following the signing of the new agreement.

The Obama administration waited months to apologize for the attack on the Pakistani soldiers because it was worried about criticism from Republicans in an election year. Anger against Pakistan is high in Washington because of the country's alleged support for militants fighting U.S. troops in Afghanistan.

But the looming deadline to withdraw most combat troops from Afghanistan by the end of 2014 increased the urgency to get the route through Pakistan reopened. U.S. officials have said the alternate northern route through Central Asia couldn't handle the estimated 100,000 containers that will have to be moved out of Afghanistan within 18 months.