The Department of Homeland Security expressed its "sincerest condolences" Thursday after reports that a 7-year-old Guatemalan girl died last week after more than eight hours in custody of U.S. Customs and Border Protection (CBP).

In a statement, DHS said CBP agents “took every possible step to save the child’s life under the most trying of circumstances.”

"Unfortunately, despite our best efforts and the best efforts of the medical team treating the child, we were unable to stop this tragedy from occurring," the statement continued.

DHS also noted the risks inherent in attempting to enter the U.S. illegally.

"Once again, we are begging parents to not put themselves or their children at risk attempting to enter illegally," the statement said. "Please present yourselves at a port of entry and seek to enter legally and safely.”

"Once again, we are begging parents to not put themselves or their children at risk attempting to enter illegally. Please present yourselves at a port of entry and seek to enter legally and safely.” — Department of Homeland Security statement

The girl had reportedly been traveling with her father and a group of 163 people before crossing the U.S.-Mexico border on Dec. 6. After crossing the border, the group approached agents to turn themselves in.

FEDS FIND GIRL, 2, STRAPPED TO CHEST OF TEEN BOY CAUGHT CROSSING US-MEXICO BORDER

The girl died of dehydration and shock more than eight hours after she was arrested by agents near Lordsburg, N.M., according to an agency statement released to the Washington Post.

CBP said the girl had not eaten or consumed water in several days. It's unknown what happened to the girl during the eight hours before she started having seizures and was flown to an El Paso, Texas, hospital.

The girl's death is under investigation by the Customs and Border Protection's Office of Professional Responsibility and the inspector general.

The agency’s detention facilities are meant to be temporary and hold a small number of people. When a Border Patrol agent arrests someone, that person gets processed at a facility but usually spends no more than 72 hours in custody. But processing 163 immigrants in one night likely posed challenges for the agency.

The Border Patrol has seen an increasing trend of large groups of immigrants, many with young children, walking up to agents and turning themselves in. Most are Central American and say they are fleeing violence in their home countries. They turn themselves in instead of trying to circumvent authorities, many with plans to apply for asylum.

Agents in Arizona see groups of more than 100 people on a regular basis, sometimes including infants and toddlers. Arresting such groups poses logistical problems for agents who have to wait on transport vans that are equipped with baby seats to take them to processing facilities, some which are at least a half-hour north of the border.

TODDLER'S DEATH AFTER LEAVING IMMIGRATION FACILITY LEADS TO $40 MILLION LEGAL CLAIM

The death of the 7-year-old girl comes after a toddler died in May just after being released from an ICE family detention facility in Texas, and as the Trump administration attempts to ban people from asking for asylum if they crossed the border illegally. A federal appeals court has temporarily blocked that ban, but the administration asked the U.S. Supreme Court to reinstate it Tuesday.

The Associated Press contributed to this report.