At least 11 Afghan soldiers were killed and 15 wounded on Monday when militants attacked an army outpost near a major military academy in Kabul.
It was the fourth major attack to hit the country in nine days.
ISIL claimed responsibility for the attack close to the Marshal Fahim military academy on the city's western outskirts, in which four of the five gunmen were killed and one captured.
It came two days after an ambulance bombing in the city centre killed more than 100 people and just over a week after another attack on the Intercontinental Hotel, also in Kabul, killed more than 20.
Both of those attacks were claimed by the Taliban.
Ministry of defence officials said the five militants, armed with rocket-propelled grenades and automatic rifles, attacked the outpost near the well-defended academy just before dawn.
Security officials at the scene said the gunmen had used a ladder to get over a wall into the post.
Afghanistan in mourning as ambulance bomb death toll crosses 100
ISIL attack leads Save the Children to halt Afghanistan aid effort
Analysis: Why Afghanistan is a war with no end in sight
In October, a suicide attacker rammed a car full of explosives into a bus carrying cadets from the academy, known as the defence university, killing 15 of them.
While militants claiming allegiance to ISIL operate in mountains in the eastern province of Nangarhar, little is known about the group and many analysts question whether they are solely responsible for the attacks they have claimed in Kabul and elsewhere.
ISIL also claimed an assault on the office of aid group Save the Children in the eastern city of Jalalabad on Wednesday in which six people were killed.
The attacks have put pressure on president Ashraf Ghani and his US allies, who have expressed growing confidence that a new, more aggressive military strategy has succeeded in driving Taliban insurgents back from major provincial centres.
The United States has stepped up its assistance to Afghan security forces and its air strikes against the Taliban and other militant groups, aiming to break a stalemate and force the insurgents to the negotiating table.
Afghan residents in despair after Kabul ambulance attack
Opinion: The complex calculations at work in Afghanistan's new theatre of conflict
Monday's attack came as Mr Ghani welcomed his counterpart from Indonesia, president Joko "Jokowi" Widodo, who arrived in Kabul for an official visit, Associated Press reported.
Mr Ghani thanked the Indonesian leader for his visit and the condolences that Mr Widodo expressed for the victims of the attack earlier in the day.
He is the first Indonesian president to visit Afghanistan since 1961.
Mr Ghani said he hoped the country would be able to benefit from Indonesia's experience in achieving a united stand from the country's clerics and confronting extremism.
Recently, a delegation of the Afghan High Peace Council, which is tasked with promoting peace efforts with the Taliban and other insurgent groups, travelled to Indonesia where authorities reaffirmed their support to the Afghan peace process.
Mr Widodo arrived in Afghanistan after visiting Pakistan, where he met with president Mamnoon Hussain.