The unrest, which started on Sunday, ended early on Monday, police said, when the inmates surrendered their weapons and freed unharmed the last of 12 guards they had taken hostage.
A prison chaplain said the riot began after a fight between rival gangs.
A number of inmates has reportedly escaped. Brazil has the world's fourth largest prison population.
There are some 600,000 inmates and overcrowding is a serious problem.
When the riot began on Sunday afternoon, six headless bodies were thrown over the perimeter fence of the Anisio Jobim Penitentiary Centre, the biggest in Amazonas state.
The prison was built for 454 inmates, but it is thought to have held almost 600. Latest available figures dating back to October suggest there were 585 prisoners in the jail back then.
Fights between rival gangs often result in dozens of inmates being killed and sometimes dismembered.
The gang members behind the deadly riots are often from violent inner-city areas of Rio de Janeiro and Sao Paulo who have been transferred to prisons in remote states in order to break up the gangs.
However, the number of deadly riots in these states would seem to indicate that this strategy has not worked out according to plan, correspondents say.
In October, at least 25 prisoners were killed in a jail in Boa Vista, in Roraima state, and seven youths also died in a riot in Caruaru in Pernambuco state.
More than 50 inmates have been killed in a prison riot in the Brazilian state of Amazonas, officials say.