The fire broke out during a dawn riot at the prison in Ponte Nova, southeast of the city of Belo Horizonte.
"We can confirm the death of 25 prisoners," a spokesman for the Minas Gerais state said.
A group of prisoners escaped from one part of the prison and entered another wing of the jail where they surrounded a rival gang, setting the mattresses in cell number eight on fire, he said.
Police used water cannon and tear gas to end the riot, and officials said none of the inmates had escaped the prison during the blaze.
Security has been stepped up inside and outside the jail which currently houses around 175 inmates, even though its capacity is only 87.
Prison officials said the fire had completely destroyed the top floor of the building, and the prison would now be evacuated with the remaining 148 detainees, including eight women, sent to other state penitentiaries.
Observers blamed severe overcrowding for the events.
"It's a complicated situation. We are short of some 100,000 places in the country's prisons," Jose Carlos Brasileiro, from the Rio de Janeiro human rights office said.
"In the Miracema women's prison for example, there are eight prisoners to a cell that measures some 1.5 meters (four feet) by two (six feet). The women don't even have mattresses and there are rats and cockroaches."
"Over-crowding and boredom are behind the violence and mutinies in the prisons."
Brazil’s security program
The fire in Ponte Nova came three days after the Brazilian government launched a national program against violence, investing more than three billion dollars over five years in the scheme.
More than 40,000 people are murdered every year across the country, and the country's Catholic church has estimated that there is a prison riot every 36 hours.
The new national security program, which mainly targets young people from poor areas, envisages building some 160 new prisons within the next four years.
Authorities in Minas Gerais reaffirmed their commitment to "ending the historic lack of places in the local prison system."
Between 2003 to 2006, some 23 new detention centers were opened in the state, and some 35,000 prisoners were held in about 45 centres, they said in statement.
A medical team was due to arrive later at the Ponte Nova jail to carry out DNA tests and compare dental records in order to identify the bodies of the dead.