Afghanistan marked a national day of mourning on Tuesday in connection with a brazen Kabul University attack that left at least 19 students and teachers dead a day earlier.

Hundreds of Kabul residents gathered in front of the university to denounce the attack, and expressed solidarity with the victims.

On the directives of President Ashraf Ghani, the national flag at public offices across the country, and diplomatic missions abroad was hoisted at half-mast.

"We convey a clear message to all terrorist groups... such acts of terror and atrocity can never deter our resolve for a peaceful, stable and thriving Afghanistan... this attack will not go without response, we will retaliate," he said in a televised speech late Monday.

While the Taliban, who are negotiating a political settlement with Kabul to end 19 years of fighting, rejected their involvement in the attack, the Daesh/ISIS terror group took credit for the bloodshed.

A statement along with a photo of two assailants carrying assault rifles was posted on the group's propaganda website Amaq.

Some 22 people were also wounded when unidentified men stormed the historical academic institution in the Afghan capital following multiple blasts and a gunfight.

A spokesman for the Interior Ministry said the attack was stopped when all the three gunmen were killed.

The attack took place as a book fair by Afghan and Iranian publishers was under way at the university.

Despite the continuing peace talks, violence in Afghanistan has worsened in recent months.

The intra-Afghan dialogue in Doha, Qatar, currently in its initial stages, follows an earlier peace agreement between the Taliban and the US in February.