WASHINGTON (AFP) - United States (US) Secretary of State John Kerry said on Wednesday he had nailed down the terms of key security pact to govern the presence of US troops in Afghanistan beyond 2014.
The hard-won agreement was announced just hours before Afghan leaders were to debate the deal.
Afghanistan's President Hamid Karzai appears to have bowed to a US demand that American troops not be tried in local courts if they are accused of any crimes, a key sticking point.
"As we sit here tonight we have agreed on the language that would be submitted to a loya jirga, but they have to pass it," Mr Kerry told reporters in Washington.
The draft text, released by Kabul earlier on Wednesday, is now set to go before the traditional Afghan assembly known as a loya jirga on Thursday.
According to the draft, US forces remaining in Afghanistan to train local security personnel and pursue Al-Qaeda after the bulk of Nato troops leave at the end of 2014 will be subject to American justice.
The Bilateral Security Agreement (BSA) is seen as vital to security in the war-torn nation, where the Taleban insurgency this year has reached levels of violence not seen since 2010, according to the United Nations (UN).
A similar deal between the US and Iraq collapsed in 2011 over whether US troops would be answerable to local courts or those in America, leading Washington to pull its forces out.
But a draft text published on the Afghan foreign ministry website said Kabul had agreed that the US should have "the exclusive right to exercise jurisdiction" over its forces in Afghanistan.
"Afghanistan authorises the United States to hold trial in such cases, or take other disciplinary action, as appropriate, in the territory of Afghanistan," it said.
According to the draft, the deal will remain in force "until the end of 2024 and beyond" unless either side terminates it.
The issue has dogged negotiations with Kabul, leading some to fear the Iraq "zero option" would be repeated and the country would plunge deeper into violence as local forces struggle to quell the Taleban.
Afghan officials could not be reached for comment on the publication.
A spokesman for the US State Department stressed that the released text was a draft and final details were still under discussion and could change.
It remains unclear how many US troops will stay on after the majority of Nato forces, who currently number 75,000, pull out. That announcement is expected to come separately from US President Barack Obama.
Mr Kerry said the remaining troops would have "a very limited role, it is entirely train, equip, and assist. There is no combat role for the United States forces". Afghan officials have said up to 16,000 could remain.
The draft deal also said that while US military operations against Al-Qaeda may be "appropriate" in the fight against terrorism, the two sides would cooperate closely to protect US and Afghan interests "without unilateral US military counter-terrorism operations."
There was no mention however of another sticking point - on whether US troops will be able to search Afghan homes.
Mr Aimal Faizi, President Karzai's spokesman, told reporters in Kabul on Tuesday they had agreed US forces could search homes, but only in "extraordinary circumstances" where there was an urgent risk to life.
Threatening to overshadow the crucial last steps on the BSA, an unexpected row blew up late on Tuesday after reports that the US would apologise for mistakes made during the Afghan war.
But Mr Kerry stressed there had never been any such discussion, saying: "I don't know where this idea of an apology started".
"President Karzai didn't ask for an apology, there was no discussion of an apology, it's just not even on the table," Mr Kerry said.
Civilian casualties and incidents such as the accidental burning of Qurans in February 2012 have caused huge anger and resentment among Afghans.
Analyst Ahmad Saeedi said it was less a row and more a piece of domestic political maneuvring from Mr Karzai, who has made numerous outbursts against Washington, his principal ally, over the years.
"Mr Karzai just wants to show he is a national hero who has been bargaining with the US for national interests till the last moment," Mr Saeedi said.
Highlighting the ongoing security challenges facing Afghanistan, a Taleban suicide bomber on Saturday struck close to the venue where the loya jirga is set to be held, killing a dozen people, mostly civilians.