Five insurgents attacked a government ministry in Kabul, an onslaught that left at least 12 dead and that came two days after the cancelation of a planned meeting of Taliban representatives with the Afghan government in a new attempt to restart the peace process.

But the Taliban did not delay in tweeting a message distancing itself from the terrorist attack.

"The Kabul attack today has nothing to do with the Islamic Emirate," the Taliban's Zabiullah Mujahid wrote.

The attack on the Ministry of Communications and Information Technology began shortly before mid-day with an explosion, Nasrat Rahimi, Interior Ministry spokesperson, told EFE.

The blast was followed by a shooting that went on almost five hours, Rahimi said.

Up to now, the slaying of the five attackers, four civilians and three members of the armed forces have been confirmed, while another eight civilians were wounded, Kabul police spokesperson Basir Mujahid, told EFE.

Mujahid said the attack began when one of the insurgents sacrificed himself with explosives, opening the way for the other four insurgents to break into the ministry complex, where they were eventually slain.

"Security forces have minimized losses and casualties of the civilians in this attack. If the attackers could get access to the main government buildings, there were thousands of employees and civilians who were visiting the ministries for their routine works, this could turn to a tragedy," the police spokesperson said.

The Interior Ministry hailed the fact that some 2,800 could be evacuated to safety.

"We will continue to combat terrorism in our country," Information and Technology Minister Shahzad Aryobee said on Twitter, and thanked security forces for having saved "above 2,000 members of our courageous personnel."

Tolo News television showed images of several individuals, presumably workers, fleeing out the windows of a ministry building, after security forces had put in place a metal ladder down to the street.

Afghan President Ashraf Ghani "strongly condemned the savage attack" in a statement and said "the Afghanistan enemies by targeting civilian services employees, attack over public institutions and creating fear once again proved that they don't have any goal, but killing and crime."

Last month, six people were killed and 23 injured in three explosions near a shrine in Kabul frequented by members of the country's Shia Muslim minority.

Saturday's attack came after the government of Qatar canceled what would have been the first-ever peace talks between the Taliban and representatives of the Afghan government in the presence of a United States delegation.

The meeting was set to be held this weekend but was canceled after the host, Qatar, rejected a list of 250 participants provided by the Afghan government.

In recent months, the US and the Taliban have held various rounds of negotiations that have not included any representation from Kabul.

However, Kabul maintains that any negotiations with the Taliban on ending the conflict that began in October 2001 must be led by Afghan authorities.