Police on Tuesday said that it was the worst jail violence in Brazil in more than 10 years.
Authorities said 15 decapitated bodies were found in the Benfica jail, which opened only a month ago, in an overnight search after the rioting ended late on Monday. Many corpses were charred.
"It was a truly horrific scene ... There were bodies dumped in garbage containers, heads, body parts," said Rio state lawmaker Geraldo Moreira, who visited the prison.
The mutinous prisoners, some of them armed with pistols and shotguns, surrendered and freed more than 20 hostages after talks mediated by a priest.
The dead included a guard who had been taken hostage. He was shot execution-style in the back on Sunday.
"It was a truly horrific scene ... There were bodies dumped in garbage containers, heads, body parts"
Rio state lawmaker
Police said earlier 34 people had died and coroners reported as many as 38 bodies, but the state security secretariat gave 30 as the final death toll on Tuesday night.
Police fired shots in the air on Tuesday to disperse a crowd of people who gathered outside the prison to find out if relatives among the prisoners were safe. No list of casualties was available.
Police officials said the violence involved rival drug gangs which control most of Rio's teeming "favelas" or slums. Many of the kingpins run their operations from behind bars.
The Benfica riot started on Saturday when a group of armed men tried to break in from the outside to free some prisoners. At least 14 inmates fled the jail then.
State officials blamed
Julita Lemgruber, former Rio state penitentiary secretary, said state authorities were wrong to incarcerate members of rival gangs in the same prisons.
Authorities say that by separating prisoners they would be tacitly giving the gangs a measure of control over the penal system.
An inmate shouts through a hole
in the wall during the prison riot
"Their idea may be correct in theory but gang wars are over 20 years old in Rio and one cannot mix them like that while the state is absent from the prison system," said Lemgruber, who now heads a violence research centre at Candido Mendes University in Rio de Janeiro.
"Inmates do not receive such basic things as toilet paper and soap, so many end up completely dominated by gang leaders just to get toilet paper," she said, adding that gangs were much more organised inside the prisons than outside.
'Worst violence since 1992'
Benfica, which has about 900 inmates compared with its capacity of 1,300, was not designed as a prison. It is a refurbished police barracks guarded by retired policemen. It was converted to accommodate some of the prisoners awaiting trial at overcrowded police stations.
The bloodshed marked Brazil's worst prison violence since the 1992 police massacre of 111 inmates at the Carandiru prison in neighboring Sao Paulo state.
Brazilian jails have seen repeated revolts, usually sparked by appalling conditions including overcrowding. In April, 14 inmates died in an Amazon prison. A riot in the same prison in 2002 claimed 27 lives.
The prison population of Rio de Janeiro state has doubled over the past decade while the number of properly trained prison guards has remained about the same due to budget constraints.