KABUL, Afghanistan — Militants stormed Afghan government offices in Kabul on Monday after setting off a car bomb, and officials said at least 43 people were killed.
The attack lasted at least five hours and shattered a period of relative calm in the Afghan capital, which over the years has been subjected to deadly and audacious assaults by militants opposed to the American-backed government.
It also came less than a week after President Trump reportedly instructed the Pentagon to prepare for the withdrawal of about half the American military contingent deployed in Afghanistan, an abrupt shift in policy that caught Afghan officials by surprise.
The attack began late in the afternoon as employees were leaving an area that houses offices belonging to the Afghan Ministry of Public Works and the administration dealing with pensions for the families of people killed and disabled in Afghanistan’s long war.
Nearly six hours after the militants entered the compound, security officials said the fighting had stopped, though clearance operations were still happening. The officials said they had managed to rescue about 350 workers stuck inside.
“Around 3 p.m., a car bomb exploded in front of the office of Martyrs and the Disabled, and following that some attackers entered the building,” said Basir Mujahid, a spokesman for the Kabul police, referring to the aid ministry.
Waheed Majroh, a spokesman for the Afghan Health Ministry, said the ministry’s ambulances had transferred 43 dead and 10 wounded.
One senior official said three attackers were also killed. The total number of assailants was not clear.
The area targeted by the militants houses the offices of several ministries, as well as several crowded apartment buildings. By Monday evening, no group had claimed responsibility, although Abdullah Abdullah, the government’s chief executive, blamed the Taliban.
Kabul had been relatively calm for the past few months, following a period of bloody violence when the Islamic State claimed repeated bombings in the capital. Officials attributed the calm to operations by Afghan security forces, with close support from the United States military, to target Islamic State cells inside the city.
The attack in Kabul came a day after President Ashraf Ghani shook up his security cabinet, introducing new interior and defense ministers at a time when violence by the Taliban has stretched Afghan forces across the country. On Monday, Mr. Ghani said a priority for the new security leadership would be to protect the heavily populated cities against such violence.
American diplomats have made an urgent push in recent months for peace talks with the Taliban to end the long war, hurrying in part because Mr. Trump has signaled that he is losing patience with the conflict and the costly American military presence in the country.
Despite several meetings with representatives of the insurgency, extended negotiations do not appear imminent. The two sides discussed the possibility of a cease-fire last week, which the Taliban representatives said they would take to their leadership.
Last Thursday, the Trump administration reportedly asked defense officials to prepare for a start to the withdrawal of 7,000 American troops from Afghanistan, about half the total deployed. The news stunned Afghan officials, as they had not been briefed about it beforehand.