JAKARTA, Indonesia — A riot and deadly two-day standoff by terrorism detainees in a police detention center near the Indonesian capital ended early Thursday after a police assault on the cellblock led to a mass surrender by those holed up inside, officials said.

Explosions could be heard from the compound as a police counterterrorism unit known as Detachment 88 fired tear gas and blew out walls in search of bombs made by a group of 156 terrorism suspects and convicted militants. Officials said that five guards and one detainee had been killed in the standoff at the detention center, in Depok, West Java Province.

Most of the inmates in the section have been linked to the Islamic State, and the terrorist group’s media arm claimed responsibility for the uprising, posting images it said showed guards that the detainees had taken hostage and then killed.

Indonesia’s influential security minister, Wiranto, said that 145 of the detainees came out and surrendered, leaving 10 holed up inside. He said officers recovered 30 weapons that the detainees had taken from guards within the compound.