At least 57 inmates were killed during a prison riot in northern Brazil on Monday as rival gang factions fought each other, an official said.