ISLAMABAD - The US and Pakistan are close to signing an agreement regulating the flow of Nato troop supplies in and out of Afghanistan, codifying a somewhat informal arrangement that has fuelled the Afghan war over the past decade, US officials said Tuesday, reported a private TV channel, quoting an American news agency.

Pakistan pushed for a written pact in drawn-out negotiations that led to the supply line’s reopening two weeks ago following a seven-month blockade. Islamabad had imposed the blockade in retaliation for American air strikes that killed 24 Pakistani soldiers on the Afghan border.

The route through Pakistan will be vital to the scheduled withdrawal of US troops from Afghanistan in 2014, one of the reasons the US finally agreed to Islamabad’s demand that it apologise for the deaths of the Pakistani soldiers. The US 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 Nato supplies that have not yet arrived in Pakistan, not the 9,000 plus 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 Nato equipment and supplies out of Afghanistan.

US and Pakistani negotiators have finalised the wording of the deal and expect it to be signed soon, two senior US officials told the news agency, speaking on condition of anonymity because of the sensitivity of the issue. Pakistani officials did not return phone calls for comment. The deal would prohibit the US and other Nato countries from shipping weapons by land into Afghanistan - as demanded by Pakistan’s parliament - but allow them to withdraw lethal items from the country, said the officials. The US-led coalition does not currently transport weapons by land through Pakistan to Afghanistan. Following the deaths of the 24 soldiers, the parliament had also demanded a ban on weapons shipped through Pakistani airspace to Afghanistan. But there is no indication that the US has complied with this condition.

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. To sweeten the deal, the US 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 US 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. Hundreds of supporters of Jamaat-i-Islami, protested on Tuesday near one of the two main crossings used to ship Nato supplies into Afghanistan. They waved party flags and banners with slogans against the US and the government, such as ”Down with America” and ”Down with American slaves,” a reference to Pakistan’s leaders.

The Obama administration, mindful of GOP criticism in an election year, waited months to apologise for the attack on the Pakistani soldiers.

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. One US official 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.