Gunmen wearing white lab coats stormed a military hospital in Afghanistan's capital on Wednesday, killing at least 30 people and wounding dozens in an attack claimed by the Islamic State group.

'G' IS FOR GUN: TROOPS FIND ISIS TEXTBOOKS USED TO BRAINWASH CHILDREN

The attack on the 400-bed military facility, located near two civilian hospitals in Kabul's heavily-guarded diplomatic quarter, set off clashes with security forces that lasted several hours.

The brazen assault reflected the capability of militant groups in Afghanistan to stage large-scale and complex attacks in the heart of Kabul, underscoring the challenges the government continues to face to improve security for ordinary Afghans.

PLO NAMES YOUTH CAMP AFTER TERRORIST WHO MURDERED 37

Gen. Dawlat Waziri, a Defense Ministry spokesman, said there were "more than 30 killed and more than 50 wounded" in the attack. Afghan forces battled the attackers floor by floor, he added. The ministry said the attackers were dressed like health workers.

According to Waziri, four gunmen were involved, including two suicide bombers who detonated their explosives vests once the group was inside the hospital.

The two other attackers were shot dead by security forces, the spokesman said. A member of the security forces was killed in the shootout and three other security officers were wounded. Along with the suicide vests, the attackers also had AK-47 rifles and hand grenades, Waziri said.

Obaidullah Barekzai, a lawmaker from southern Uruzgan province, said Wednesday's attack by the Islamic State group and other similar assaults, especially in the capital, are very concerning.

"This is not the first attack by the Islamic States group, they have carried out several bloody attacks in Kabul," he said.

The assault lasted for several hours, with Afghan helicopters circling over the hospital building, troops rappelling onto rooftops and security forces going floor-by-floor in a gunbattle with the attackers. By mid-afternoon, the attack was over and a clean-up operation was underway.

Abdul Qadir, a hospital worker who witnessed the attack, said an attacker in a white coat shot at him and his colleagues. Ghulam Azrat, another survivor, said he escaped through a fourth floor window after attackers killed two of his friends.

IS claimed the attack in a statement carried by its Aamaq news agency.

An affiliate of the extremist group has carried out a number of attacks in Afghanistan in the last two years, and has clashed with the more powerful and well-established Taliban, who carried out another complex attack in Kabul last week.

Mohammad Nahim, a restaurant worker in Kabul, said he worries that IS militants are getting stronger. "Daesh has no mercy on the humanity," he added, using an Arabic name for the group.

Afghan security forces have struggled to combat both groups since the U.S. and NATO formally concluded their combat mission at the end of 2014, switching to an advisory and counterterrorism role.

Afghan President Ashraf Ghani condemned Wednesday's attack during an address in honor of International Women's Day, calling it "an attack on all Afghan people and all Afghan women."

The foreign ministry in neighboring Pakistan condemned the Kabul attack, describing it as a "heinous terrorist attack" and expressing Islamabad's condolences to the victims.

The acting U.N. humanitarian coordinator for Afghanistan, Adele Khodr, warned in a statement that hospitals, medical staff and patients "must never be placed at risk, and under no circumstances be subject to attack" and urged all parties in the conflict to abide by and "respect all medical workers, clinics and hospitals in compliance with international law."

She said that in 2016, at least 41 attacks on health care facilities and workers were recorded across Afghanistan -- "an appalling catalogue of attacks that ultimately further hinders delivery of essential and life-saving health care to all Afghans across the country."