DUSHANBE, Tajikistan — Three guards and 29 inmates were killed in an outbreak of violence involving Islamic State militants at a high-security prison in Tajikistan, the Justice Ministry said on Monday.

The ministry said rioting broke out late Sunday at the prison in Vakhdat, about six miles east of the capital, Dushanbe, after militants armed with knives killed the guards and five fellow prisoners. Security forces responded to the violence, killing 24 militants and restoring order at the prison, which holds 1,500 inmates, the ministry added.

Two of the prisoners who were killed were senior members of the Islamic Renaissance Party of Tajikistan, an Islamist party outlawed by the government of President Imomali Rakhmon in 2015. Another was a prominent Tajik cleric who had been convicted on charges of calls to overthrow the government.

One of the instigators of the riot was Bekhruz Gulmurod, a son of Gulmurod Khalimov, a Tajik special forces colonel who joined the Islamic State, also known as ISIS or ISIL, in 2015 and, according to the Justice Ministry, has since been killed in Syria. The fate of Bekhruz Gulmurod after the riots was not publicly known.