KABUL — The Taliban exploded a car outside the gate of a NATO base in the western Afghan city of Herat on Monday, setting off a gun battle as a bomber blew up amid a downtown crowd, Afghan officials said.

The car bomb targeted the Italian military-led Provincial Reconstruction Team office, which coordinates the coalition’s support for development and governance in the province. The Italian defense minister said five Italian soldiers were wounded, including one critically, according to the Associated Press.

The other blast occurred around the same time in an area of Herat called Cinema Circle, killing at least four Afghan civilians and wounding 37 others, according to Mohammad Rahim Panjshiri, head of the Afghan intelligence agency in the province. AP reported that a suicide bomber blew up a car at a bus stop in the area.

As the car bomb went off at the Italian base, four insurgents in explosive vests entered a building nearby and and began firing from the windows down into the base, Panjshiri said. By afternoon, Afghan and coalition troops had secured the are, he said. The provincial governor said four of the five attackers were killed and one was arrested.

The Taliban claimed responsibility for the violence. An insurgent spokesman, Qari Mohammad Yousef, said that up to four fighters with grenades, guns and explosives took part.

The assault on the NATO compound was the first major attack in downtown Herat since the Taliban went after the United Nations office in the city in October. Guards fought off that assault, and there were no U.N. casualties.

Near the border with Iran and Turkmenistan, Herat is among the few secure parts of Afghanistan, and attacks, particularly in the city, are rare. Herat is identified as one of the first areas to be transferred to Afghan security force control starting in July when U.S. troops begin to withdraw.

Also on Monday, a man wearing an Afghan National Army uniform in southern Afghanistan opened fire on a NATO service member and killed him. Another NATO soldier died during a helicopter “hard landing” in the south.

Special correspondent Sayed Salahuddin in Kabul contributed to this report.

Joshua Partlow is The Washington Post’s bureau chief in Mexico. He has served previously as the bureau chief in Kabul and as a correspondent in Brazil and Iraq.