An illegal immigrant who became "unruly" and tried to escape from border agents in Texas died while in custody this week, officials said Friday.

Border Patrol agents were tracking a group of migrants near Eagle Pass for nine hours when they took seven of them into custody while the others fled, the U.S. Customs and Border Protection agency said. 

The migrant who died, a man from El Salvador, was part of a group of five migrants who were taken into custody shortly after the first group. He was handcuffed with two other migrants.

"The man reportedly became unruly and was causing discomfort to the other two individuals to whom he was attached," the CBP said. 

NEW IMAGES SHOW EXPANSION OF MIGRANT FACILITY IN DONNA, TEXAS AS CRISIS RAGES

U.S. Customs and Border Protection patrolling in Nogales, Arizona. (Stephanie Bennett/Fox News).

When the border agents removed the handcuffs he allegedly tried to escape before being caught a short distance later.

He was restrained with a hand behind his back and placed on the hood of a Border Patrol vehicle. The agents then took the migrants back to where the first group was to wait for a transport vehicle.

The Salvadoran man remained restrained. When the transport vehicle arrived an hour later, he was found "unresponsive," the agency said. 

Agents began chest compressions and requested emergency medical services. The Eagle Pass Fire Department responded and the man was pronounced dead.

An investigation into the death is ongoing and the agents involved have been reassigned pending the inquiry. The incident comes amid criticism of how migrants are detained and the conditions of detention facilities. 

CLICK HERE TO GET THE FOX NEWS APP

On Wednesday, the CBP announced it had begun deploying body-worn cameras to agents and officers in a transparency effort to document use of force incidents and allegations of misconduct. 

"Providing them with state-of-the-art technology and tools like body-worn cameras will support their work and provide greater transparency into interactions between CBP officers and agents and the public," Troy Miller, CBP acting commissioner, said in a statement.