RIO DE JANEIRO — Some of the inmates were beheaded. Others had their hearts torn from their bodies. Gang leaders used the blood of their victims to write a nightmarish message of retribution: “Blood is paid for with blood.”

The harrowing scenes on Friday from the latest prison riot in Brazil, in which 31 inmates were killed in the northern state of Roraima in the Amazon River Basin, pushed the death toll to 93 in six days of mayhem in penitentiaries around the country.

The bloodshed has shocked the country and is emerging as the most pressing crisis facing President Michel Temer, whose beleaguered government was already grappling with graft scandals, a weak economy and simmering anger over austerity measures.

“The bloodshed is revealing a war between drug gangs, a failed prison system and a weak government,” said Rafael Alcadipani, a scholar who specializes in public security policies at Fundação Getúlio Vargas, a leading Brazilian university. “And now the horror is spreading.”