The Afghan government has signed a peace agreement with Hezb-e-Islami, the country's second largest militant group.
Representatives of the movement and Afghan officials signed the accord in a ceremony shown live on TV.
The deal grants immunity to the group's leader Gulbuddin Hekmatyar, an Islamist warlord accused of numerous atrocities.
He was not present at the signing, which is intended to pave the way for him to return from hiding to Kabul.
Mohammad Amin Karim, head of the insurgent delegation, was present at the ceremony.
He said: "This is not just a peace deal between Hezb-e-Islami and the government of Afghanistan, it is a beginning of a new era of peace all around the country."
Under the terms of the deal, Mr Hekmatyar agrees to accept the constitution and abandon violence. He must still sign the accord with Afghan President Ashraf Ghani for it to come into force.
The two sides have still to agree when and where that will happen.
Who is Gulbuddin Hekmatyar?
Mr Hekmatyar is a former Afghan prime minister, warlord and one of the most controversial figures in the country's modern history.
He was one of seven anti-Soviet faction chiefs who led a large number of mujahideen fighters in the war against Soviet occupation in the 1980s. He received significant Western aid and funds during the Cold War.
But he is remembered mostly for his role in the bloody civil war of the 1990s, when the Hezb-e-Islami clashed violently with other mujahideen factions in the struggle for control of the capital, Kabul.
The Hezb-e-Islami was blamed for much of the terrible death and destruction of that period, which led many ordinary Afghans to welcome the emergence of the Taliban.
The civil war also led to Mr Hekmatyar's fall from grace - he quickly became one of the most reviled men in the country and he and his men were forced to flee Kabul when the Taliban swept into power in 1996.
In 2003, the US state department designated him as a terrorist, accusing him of taking part in and supporting attacks by al-Qaeda and the Taliban.
Will the deal change anything, and will it hold?
It is still too early to tell if the deal will last. Mr Hekmatyar has a history of shifting allegiances.
Hezb-e-Islami has played a minor role in the Taliban-led insurgency in recent years and so the deal is not expected to improve security in the country.
The accord is highly symbolic, however. It is the first first deal done by Afghans with no UN or international mediation. And Hezb-e-Islami has supporters across the country, meaning the peace agreement could encourage some Taliban leaders to consider joining the process.
BBC Afghan Service editor Waheed Massoud says Mr Hekmatyar appears to have calculated that he will be more significant as a political leader in Kabul than as the leader of a group of fighters up in the mountains who are also competing with the Taliban for influence.
Afghan peace deals have failed before, and a lot remains to be worked out. Mr Hekmatyar still has to negotiate with the Afghan government over where and when he and Mr Ghani will sign the accord, and under what circumstances he will return to Kabul.
There are also concerns about his future role in Afghanistan. Seen as a controversial and attention-seeking figure, he could become more of a headache for Kabul than when he was a rebel leader - potentially forming new coalitions and challenging the government.
What was the reaction to the agreement?
Franz-Michael Mellbin, the European Union's special representative for Afghanistan, said of the agreement "proves peace is possible".
"The political space to say no to peace in Afghanistan is now virtually non-existent," he said, adding that the deal "creates a new narrative that has been missing for many, many years".
Ahmad Gilani, the chairman of the Afghan High Peace Council, welcomed the agreement: "I am happy and confident on the finalising of this agreement, that it will be a good start for long lasting peace and stability in Afghanistan."
But New York-based Human Rights Watch issued a statement referring to Mr Hekmatyar as "one of Afghanistan's most notorious war crimes suspects". Researcher Patricia Grossman said his return would "compound the culture of impunity that the Afghan government and its foreign donors have fostered by not pursuing... Hekmatyar and other warlords".
A group of activists protested in Kabul, holding placards portraying Mr Hekmatyar with blood spilling from his mouth and a rocket piercing his nose. One placard read: "We cannot forgive the executioner of Kabul."
Some ordinary Afghans welcomed the agreement. Mohammad Hanif, 62, a shopkeeper, told the Associated Press: "We are thirsty for peace and we welcome anyone who comes in peace, the past is the past."
Taliban spokesman Zabihullah Mujahid said it was too early to comment on the deal.