KABUL, Nov 19 (Reuters) - The United States and Afghanistan have agreed a final version of a crucial security pact outlining where and how many U.S. troops can remain in Afghanistan after most foreign forces leave the country next year, an Afghan official said on Tuesday.
Thousands of Afghan tribal and political leaders are due to gather in Kabul this week to decide whether to allow U.S. troops to stay after the 2014 drawdown of foreign forces.
The last-minute deal was reached just two days before they gather to debate the pact. It will contain provisions to give U.S. troops immunity from Afghan law and allow them to enter Afghan homes in exceptional circumstances.
Afghan President Hamid Karzai has long objected to both but the United States has said the provisions are crucial in order for its forces to remain in the country beyond 2014.
Aimal Faizi, a Karzai spokesman, said the agreement was partly owed to a promise by U.S. President Barack Obama to write a letter to the Afghan people acknowledging mistakes made during the 12-year war.
"Both sides agreed that Obama send a letter ... assuring the president and the people of Afghanistan that the right to enter into Afghan homes by U.S. forces and the extraordinary circumstances will not be misused," Faizi told reporters.
Previously, Karzai had planned to present the tribal elders with two versions of the pact, which would have increased the chances of key U.S. demands being rejected and it pulling all its troops out after 2014.
"The whole idea of having a letter was to acknowledge the suffering of the Afghan people and the mistakes of the past. That was the only thing that satisfied the president," Faizi added.
The letter is to be presented along with the draft at the meeting of tribal elders that is due to start on Thursday and un for several days.
If the council votes in favour of the pact with the United States, it will still need the approval of both houses of parliament and the president's signature before it is ratified.
(Reporting by Jessica Donati; Editing by Maria Golovnina and Alison Williams)