Afghanistan's grand assembly or loya jirga has agreed on a new constitution that aims to bring stability and unity to a nation ravaged by war.
The forum reflected Afghanistan's ethnic diversity
It envisages a powerful presidency - in line with the wishes of current leader Hamid Karzai - and two vice-presidents.
The constitution is designed to consolidate an ethnically diverse state able to stand up to Taleban insurgents.
Agreement was reached after three weeks of heated debate that exposed the country's fragile ethnic relations.
But President Karzai told the gathering: "There is no winner or loser."
"Everybody has won."
"I want an Afghanistan where a poor boy from the Baluch tribe can become president," Mr Karzai said, referring to one of the country's clan.
US President George W Bush welcomed the constitution.
"A democratic Afghanistan will serve the interests and just aspirations of all of the Afghan people and help ensure that terror finds no further refuge in that proud land," Mr Bush said in a statement.
Divisions over official languages and whether ministers could have dual citizenship had delayed the agreement.
Finally deals were brokered behind the scenes to reach Sunday's successful conclusion.
"I invite you to stand up in a sign of approval of the new constitution," the loya jirga chairman Sibghatullah Mujaddedi said.
The overwhelming majority of the 502 delegates meeting in a big tent in Kabul got to their feet, approving the new charter by consensus rather than an actual vote.
President Karzai has been struggling to quell ethnic rivalry
Ratifying a new constitution is a key requirement of the Bonn agreement, the peace accord signed in December 2001 after the Taleban were toppled from power by the United States military.
But the BBC's Crispin Thorold in Kabul says after such a divisive meeting, strong leadership and compromise among the factions will be essential to ensure the constitution is accepted by the vast majority of Afghans.
In many ways the hard work begins now with implementation of the constitution, he says.
Since the last constitution was drawn up in 1964, Afghanistan has seen Soviet occupation, civil war and five years of hardline Taleban rule.
Islamic Sharia law is not specifically mentioned in the document.
But observers say one article could allow Sharia to be introduced by the back door.
One of the thorny issues was whether Uzbek should be recognised as an official language.
Some delegates were opposed to the Uzbek language being recognised as official along with Pashto, spoken by Pashtuns who form the majority of Afghans, and Dari, spoken by Tajiks.
There is intense rivalry between the Pashtuns, who have traditionally dominated Afghan political life, and smaller groups like the Tajiks, Uzbeks and Hazaras.
Agreement was reached to have Pashto and Dari as the two official languages.
The tongues of the minority ethnic groups will be third official languages in the areas where those communities are in the majority.
The divisive issue of the dual nationality of ministers was also resolved.
If a minister in the new government holds citizenship of two countries, it is believed that parliament will vote on that appointment.
Many of President Karzai's cabinet ministers hold dual nationality.
UN special envoy Lakhdar Brahimi congratulated Afghanistan on its new constitution but warned "that there is no rule of law in this country yet".
Despite the presence of international peacekeepers in parts of the country, militias and warlords still hold sway in many regions.