KABUL (Reuters) - Gunmen who raided a government building in the Afghan capital killed at least 28 people - mostly government employees - and wounded more than 20 others in a seven-hour standoff with police that ended on Monday night, Afghan authorities said.

Others killed included a policeman and three of the attackers who were shot dead by Afghan security forces, Interior Ministry spokesman Najib Danish said.

The attack began in the afternoon when a suicide bomber blew himself up in a car outside the public works ministry. Militants then stormed the building of the National Authority for Disabled People and Martyrs’ Families, taking civilians hostage as they fought a gun battle against Afghan soldiers.

Afghan security forces went from floor to floor of the building in an operation to rescue over 350 people inside, but had to exercise restraint in their operations against the attackers given the number of employees there, a senior security official said.

No militant group immediately claimed responsibility for the attack.

Ambulances raced to the scene during a lull in the shooting, a witness who lives nearby told Reuters. At least 20 people wounded in the clashes were taken to hospital.

An official working in another government building close by said employees had locked themselves in their offices after hearing the explosions and gunfire. During the standoff, the building’s second floor caught fire, local news channels reported.

Slideshow ( 3 images )

Attacks on government offices are frequent and are generally carried out by the Islamist Taliban, who are fighting to expel foreign forces from strategic provinces, topple the Western-backed government and restore their version of hardline Islamic law.

The 17-year-old war with the Taliban has seen both fighting and diplomacy intensify in recent months.

On Thursday, an official said U.S. President Donald Trump was planning to withdraw at least 5,000 of the 14,000 U.S. troops in Afghanistan, a day after Trump unexpectedly announced that U.S. troops in Syria would be withdrawn.

The United States went to war in Afghanistan in 2001 in the wake of the Sept. 11, 2001 attacks on the World Trade Center in New York and the Pentagon in Washington, seeking to oust the Taliban militants harboring Saudi-raised militant Osama bin Laden, who led plans to carry out the attacks.

At present, American troops make up the bulk of the Resolute Support mission to train and advise Afghan forces fighting the Taliban and the Islamic State militant group. Others are part of a U.S.-led counter-terrorism mission.

The prospect of a U.S. drawdown has triggered widespread uncertainty in war-torn Afghanistan.

With security deteriorating, Afghan President Ashraf Ghani on Sunday replaced his defense and interior ministers with two uncompromising opponents of the Taliban.