Recent Afghan history has been marked by almost constant war
Afghanistan's descent into conflict and instability in recent times began with the overthrow of the king in 1973.
Zahir Shah was in Italy for an eye operation when he was deposed in a palace coup by his cousin, Mohammad Daoud.
Daoud declared Afghanistan a republic, with himself as president.
He relied on the support of leftists to consolidate his power, and crushed an emerging Islamist movement.
But towards the end of his rule, he attempted to purge his leftist supporters from positions of power and sought to reduce Soviet influence in Afghanistan.
Zahir Shah - Afghan king for four decades
It was this that helped lead to a defining moment in Afghanistan's recent history - the communist coup in April 1978, known as the Saur, or April Revolution.
President Daoud and his family were shot dead, and Nur Mohammad Taraki took power as head of the country's first Marxist government, bringing to an end more than 200 years of almost uninterrupted rule by the family of Zahir Shah and Mohammad Daoud.
But the Afghan communist party, the People's Democratic Party of Afghanistan - or PDPA - was divided, and splits emerged.
Hafizullah Amin, who had become prime minister, was opposed to Taraki, and in October 1979 Taraki was secretly executed, with Amin becoming the new president.
Soviet forces left in 1989
Amin, known for his independent and nationalist inclinations, was also ruthless.
He has been accused of assassinating thousands of Afghans.
To the Soviets in Moscow, he was looked upon as a threat to the prospect of an amenable communist government bordering Soviet Central Asia.
In a swift chain of events in December 1979, Amin was assassinated and the Soviet Red Army swept into Afghanistan.
Babrak Karmal was flown from Czechoslovakia, where he was Afghan ambassador, to take over as the new president, albeit as a puppet leader acceptable to Moscow.
The Soviet occupation, which lasted until the final withdrawal of the Red Army in 1989, was a disaster for Afghanistan.
About a million Afghans lost their lives as the Red Army tried to impose control for its puppet Afghan government. Millions more fled abroad as refugees.
The mujahideen could not share power
Groups of Afghan Islamic fighters - or mujahideen - fought endlessly to try to force a Soviet retreat, with much covert support from the United States.
After nearly 10 years, the Soviet Union eventually withdrew, leaving in power President Najibullah, who had replaced Karmal as leader.
He hung on for three years after the Red Army's departure, but fell in 1992 as the United Nations was trying to arrange a peaceful transfer of power.
The mujahideen swept victoriously into Kabul. After a short interim measure, Professor Burhanuddin Rabbani became president of the new Islamic Republic.
But their victory was soon soured by infighting, as the mujahideen factions failed to agree on how to share their new power.
During the Soviet occupation it was predominantly rural areas that suffered military onslaught as the Red Army tried to flush out the mujahideen.
Afghanistan's war-torn past still haunts its future
But when the mujahideen took over, it was the turn of urban areas to suffer from the conflict.
This was especially true of the capital, Kabul, about half of which was literally flattened. Tens of thousands of civilians lost their lives, and the country slid more and more into a state of anarchy.
It was towards the end of 1994 that the Taleban emerged in the southern city of Kandahar, heart of Afghanistan's Pashtun homeland.
Their initial appeal - and success - was based on a call for the removal of the mujahideen groups.
At first they succeeded in gaining control of Pashtun areas with little fighting. Mujahideen commanders defected to their ranks.
But as their control spread to other, especially non-Pashtun, areas, the fighting intensified.
The Taleban went on to control about 90% of the country.
The Taleban were toppled after the 9/11 attacks on the US
It was in 1996, as they captured Kabul, that much of the outside world first reacted in dismay to the Taleban's extreme Islamic policies, especially towards the place of women in society.
As Taleban control spread, the Western world intensified pressure on the Taleban to ban the growth of opium poppies, Afghanistan being the source of most opiates reaching Europe.
The United States, in particular, also began their pressure on the Taleban to give up the militant Saudi, Osama Bin Laden, whom the Taleban described as their "guest" in Afghanistan.
Washington blamed Bin Laden for masterminding the suicide attacks on the World Trade Centre in New York and the Pentagon in Washington on 11 September 2001.
The following month the US and its allies began air attacks on Afghanistan which allowed the Taleban's Afghan opponents to sweep them from power. Kabul was retaken in November and by early December the Taleban had given up their stronghold of Kandahar.
Road to elections
On 5 December 2001 Afghan groups agreed a deal in Bonn for an interim government, at the head of which Pashtun royalist Hamid Karzai was then sworn in.
The Bonn conference, held under UN auspices, forged a political blueprint leading to elections scheduled for summer 2004.
Karzai (right) shows the constitution to former king Zahir Shah
In June 2002 a loya jirga, or grand council, elected Mr Karzai as interim head of state. A second loya jirga in January 2004 adopted a new constitution.
In September, 2002, Mr Karzai survived an assassination attempt in Kandahar blamed on the Taleban. There have been other near misses since. A number of his ministers and other senior figures have been less fortunate.
Mr Karzai has been able to exert little control beyond the capital.
Turf wars between local commanders have been a feature of the post-Taleban period.
And the Taleban themselves have re-emerged as a fighting force, worsening the security situation first in the east and south-east, and then across much of the country.
Thousands have been killed in the violence in recent years, including many militants and foreign and Afghan troops, as well as large numbers of civilians.