Who are the Taliban?
The hardline Islamic Taliban movement has proved to be a formidable fighting force in Afghanistan and a major threat to its government.
The Taliban have also threatened to destabilise Pakistan, where they have controlled areas in the north-west in recent years. Despite a major military offensive against them since 2014, they continue to mount frequent suicide bombings and other attacks across the country.
Many observers now believe that future peace in Afghanistan can only come if the government in Kabul negotiates with the Taliban.
The announcement of Taliban plans to open an office in Qatar in June 2013 was seen as a positive step in those negotiations, but mistrust on both sides remains high.
Despite this, talks between the Taliban and Afghan government officials took place for the first time in July 2015.
Those talks came a month after a group of Afghan women met Taliban representatives in Oslo. Further contacts with the group have failed to make progress.
In September 2015, the Afghan Taliban said they had put aside weeks of infighting and rallied around a new leader in the form of Mullah Mansour, who had been the deputy of longstanding leader Mullah Omar.
The previous month the Taliban admitted they had covered up Mullah Omar's death for more than two years.
Mullah Mansour was killed in a US drone strike in May 2016 and replaced by his deputy Mawlawi Hibatullah Akhundzada, a hardline religious scholar.
The Taliban emerged in the early 1990s in northern Pakistan following the withdrawal of Soviet troops from Afghanistan.
A predominantly Pashtun movement, the Taliban came to prominence in Afghanistan in the autumn of 1994.
It is commonly believed that they first appeared in religious seminaries - mostly paid for by money from Saudi Arabia - which preached a hard line form of Sunni Islam.
The Taliban's promise - in Pashtun areas straddling Pakistan and Afghanistan - was to restore peace and security and enforce their own austere version of Sharia, or Islamic law, once in power.
In both countries they introduced or supported Islamic punishments - such as public executions of convicted murderers and adulterers and amputations of those found guilty of theft.
Men were required to grow beards and women had to wear the all-covering burka.
The Taliban banned television, music and cinema and disapproved of girls aged 10 and over from going to school.
Pakistan has repeatedly denied that it was the architect of the Taliban enterprise.
But there is little doubt that many Afghans who initially joined the movement were educated in madrassas (religious schools) in Pakistan.
Pakistan was also one of only three countries, along with Saudi Arabia and the United Arab Emirates (UAE), which recognised the Taliban when they were in power in Afghanistan from the mid-1990s until 2001.
It was also the last country to break diplomatic ties with the Taliban.
Although Pakistan has in recent years adopted a harder line against Taliban militants carrying out attacks on its soil, Prime Minister Nawaz Sharif - who was elected in May 2013 - has said talking to the militants is one of his priorities.
At least three key leaders of the Pakistani Taliban were killed in US drone strikes in 2013. Mullah Nazir was killed in January and Waliur Rehman was killed in May.
In November 2013, the group's leader in Pakistan, Hakimullah Mehsud, was killed in a drone strike.
But despite these setbacks for the militants, there is evidence that their influence in Karachi has significantly increased.
What is arguably one of the most internationally criticised of all Pakistani Taliban attacks took place in October 2012, when schoolgirl Malala Yousafzai was attacked on her way home in the town of Mingora.
The attention of the world was drawn to the Taliban in Afghanistan following the attacks on the World Trade Centre in September 2001.
The Taliban in Afghanistan were accused of providing a sanctuary to Osama Bin Laden and the al-Qaeda movement who were blamed for the attacks.
Soon after 9/11 the Taliban were driven from power in Afghanistan by a US-led coalition, although their leader Mullah Mohammad Omar was not captured.
In recent years the Taliban re-emerged in Afghanistan and grew far stronger in Pakistan, where observers say there is loose co-ordination between different Taliban factions and militant groups.
The main Pakistani faction was led by Hakimullah Mehsud until his death. His Tehrik-e Taliban Pakistan (TTP) is blamed for dozens of suicide bombings and other attacks.
Observers warn against over-stating the existence of one unified insurgency against the Pakistani state, however.
For years the Taliban in Afghanistan were led by Mullah Omar, a village clergyman who lost his right eye fighting the occupying forces of the Soviet Union in the 1980s.
Afghans, weary of the mujahideen's excesses and infighting after the Soviets were driven out, generally welcomed the Taliban when they first appeared on the scene.
Their early popularity was largely due to their success in stamping out corruption, curbing lawlessness and making the roads and the areas under their control safe for commerce to flourish.
From south-western Afghanistan, the Taliban quickly extended their influence.
They captured the province of Herat, bordering Iran, in September 1995.
Exactly one year later, they captured the Afghan capital, Kabul, after overthrowing the regime of President Burhanuddin Rabbani and his defence minister, Ahmed Shah Masood.
By 1998, they were in control of almost 90% of Afghanistan.
They were accused of various human rights and cultural abuses. One notorious example was in 2001, when the Taliban went ahead with the destruction of the famous Bamiyan Buddha statues in central Afghanistan, despite international outrage.
On October 7, 2001, a US-led military coalition invaded Afghanistan and by the first week of December the Taliban regime had collapsed.
Mullah Omar and his comrades evaded capture despite one of the largest manhunts in the world.
Many senior Taliban leaders take refuge in the Pakistani city of Quetta, from where they guide the Taliban, analysts say.
But the existence of what is dubbed the "Quetta Shura" is denied by Islamabad, even though there is much evidence to the contrary.
Despite ever higher numbers of foreign troops, the Taliban have steadily extended their influence, rendering vast tracts of Afghanistan insecure, and violence in the country has returned to levels not seen since 2001.
Their retreat in the years after 2001 enabled them to limit their human and material losses and return with a vengeance.
There have been numerous Taliban attacks on Kabul in recent years and, in September 2012, the group carried out a high-profile raid on Nato's Camp Bastion base.
In the same month the US military handed control of the controversial Bagram prison - housing more than 3,000 Taliban fighters and terrorism suspects - to the Afghan authorities.
In September 2015 the Taliban seized control of a provincial capital for the first time since their defeat in 2001, taking control of the strategically important city of Kunduz.
The US is keeping close to 10,000 troops in Afghanistan, but the Taliban finds itself an increasingly splintered organisation - that is also threatened by the rise of the so-called Islamic State militant group in Afghanistan.