SAN JOSE PINULA, Guatemala -- A fire swept through the female section of a crowded children’s shelter near Guatemala City early Wednesday and officials said at least 22 girls died and dozens more were injured.

Photos from inside the shelter showed blue sheets covering sneaker-clad bodies and bits of foam mattresses in what appeared to be a smoke-stained dormitory room.

Weeping, distraught relatives waited outside the walled facility for news of their children. Shelter personnel gave them pieces of paper to write down their children’s names so they could try to locate them.

Get Breaking News Delivered to Your Inbox

The head of Guatemala’s social welfare agency, Carlos Rodas, said youths at the shelter started rioting Tuesday in an effort to escape. Complaints about abuse and living conditions at the overcrowded shelter have been frequent.

Then on Wednesday, about 9 a.m., “Some of the adolescents lit their mattresses on fire,” Rodas said. “We don’t shirk responsibility, we accept it, but we can’t get those lives back.”

Julia Barrera, spokeswoman for the prosecutor’s office, said late in the day that at least 20 children and teenagers perished. Two hospitals said they received 41 injured girls between the ages of 13 and 17, many with second- and third-degree burns. Dr. Carlos Soto, director of Roosevelt Hospital, said some of the injured had life-threatening burns.

Rodas said the shelter had an official capacity of 500, but was housing at least 800 youths.

Family members react as they wait for news of their loved ones after a fire broke at the Virgen de Asuncion home in San Jose Pinula, on the outskirts of Guatemala City, Guatemala March 8, 2017. Saul Martinez, Reuters

A 15-year-old girl being treated for minor injuries at Roosevelt Hospital said the uprising followed rumors of an escape attempt. Some boys, or even young men who were still housed at the center after turning 18, entered the girls’ area, she said. She said she fled to her dormitory’s roof with others fearing the boys would attack them.

Early Wednesday morning the fire began. “I saw the smoke in the place. It smelled like flesh,” the girl said.

Mario Cruz, spokesman for volunteer firefighters, said the fire appeared to have started in one of the girls’ living areas and spread to another dormitory.

The government-run shelter, known as the Virgin of the Assumption Safe Home, is in a rural area outside the capital. The campus is surrounded by trees and a 30-foot wall. It houses at-risk children who were victims of abuse as well as youths who completed sentences at youth detention centers and had nowhere else to go.

President Jimmy Morales’ office said there would be three days of mourning and issued a statement confirming at least 15 deaths and said the cause of the fire was under investigation. The president held a moment of silence to mark the tragedy during a previously scheduled event to commemorate International Women’s Day.

Attorney General Annabella Morfin said children in a protective situation should not be housed with children who have problems with the law and called for an investigation of those responsible.

Candles are lit for victims after a fire broke out at the Virgen de Asuncion home in San Jose Pinula on the outskirts of Guatemala City, March 8, 2017. Saul Martinez, Reuters

Jorge de Leon, Guatemala’s human rights prosecutor, said in a statement that at least 102 children had been located after escaping from the shelter and more had managed to flee. De Leon said younger children fled the shelter because they were being abused by the elder children.

“According to what they say, the bigger kids have control and they attack them constantly,” de Leon wrote. “They also complain that food is scarce and of poor quality.”

He called on authorities “to evaluate whether it is appropriate to have these different groups concentrated in one place.”

In 2013, a 14-year-old girl was murdered at the facility. Investigators said the girl was strangled by one of the other residents.