The girl escaped early Saturday and sought help from a jail guard, who took her to the police, said Fabiano Amazonas, head of the juvenile division of police in Para state.
The director of Heleno Fragoso prison and 19 other people working there between Friday night and Saturday morning have been fired, Aycha Nunes, spokeswoman for the Para prison system, said. The decision became official Monday.
The teenager has testified she was drugged, beaten and taken by a woman along with two other teenagers into the prison, which is 26 miles (42 kilometers) from the state capital, Belem.
Amazonas said he believes the girl was taken into the prison by someone intending to charge prisoners money to have sex with her.
"She said she was abused by several inmates inside the prison, but managed to escape," he said.
Investigators are trying to determine who took the teenager into the prison, who allowed her entry, who participated in the alleged assault, and whether there were other girls involved.
On Saturday, the girl was handed over to the police's juvenile division, where she testified. She was also taken to a hospital so she could be examined for evidence, Amazonas said. The girl was then housed in a shelter.
The state's governor, Simao Jatene, ordered a wall built around the prison to increase security, according to a press statement issued Monday. The penitentiary works on a semi-open regimen, with inmates free to leave during the day. There is no fence, and the back of the building is surrounded by jungle.
The federal prosecutor's office in Belem said it has started an administrative investigation to learn where the system failed and prevent cases like this from happening again.
"The facts show a violation of human dignity, a disrespect of the basic rights of this child, a serious violation of human rights," said the regional federal prosecutor for civil rights, Alan Mansur Silva.
It is not the first case of a girl allegedly being abused inside a men's prison in Para state.
In 2007, a teenage girl arrested on petty theft charges was locked up in a jail cell with 21 men for nearly a month in Abaetetuba, a city of 78,000 people outside Belem. She was forced to have sex with them in exchange for food and was released only after her case was reported by local media.
The case shocked Brazilians, and then-Gov. Ana Julia Carepa told The Associated Press at the time that the practice of locking women up with men, while illegal, was not uncommon.
Carepa also said she was aware of the "unfortunate practice" of putting young women in cells with men purposely for the male prisoners' sexual gratification. Carepa then said this wouldn't be allowed to happen again.
(This version CORRECTS name of prison to Heleno Fragoso, instead of Heleno Pragos.)