A US border patrol agent attempting to separate a migrant family asked a 3-year-old Honduran girl to choose which of her parents got to stay in the country and which was sent back to Mexico, the couple claimed in a report.

The asylum-seeking family, parents Tania and Joseph, their toddler Sophia — nicknamed Sofi — and their two other children were nearly separated at a Border Patrol holding facility in El Paso, Texas, last week, NPR reported.

“The agent asked [Sofi] who she wanted to go with, mom or dad,” said Tania, whose last name is being withheld by the outlet.

“And the girl, because she is more attached to me, she said mom,” Tania continued. “But when they started to take [my husband] away, the girl started to cry. The officer said, ‘You said [you want to go] with mom.'”

The family — who fled Honduras after threats from the MS-13 gang — crossed into El Paso in April and were sent back to Juárez, Mexico, under a Trump administration program called Migrant Protection protocols, also known as “remain in Mexico,” NPR reported.

The program requires thousands of Central American migrants to wait in cities in Mexico while their immigration cases move through US courts.

At a hearing in Texas Wednesday, the family’s lawyer, Linda Rivas of Las Americas Immigrant Advocacy Center, asked that they be removed from the program because Sofi has a heart condition.

Immigration Judge Nathan Herbert said he couldn’t remove the family from MPP but asked the Department of Homeland Security lawyer to take note of the concerns over the child’s medical issues.

A doctor examined the girl Thursday and told Border Patrol agents she had a serious heart condition. The Border Patrol agents eventually agreed to allow some of the family to remain in the US.

The agent “told me: ‘Sign here, because we are giving you and your children permission.’ And I said, ‘I came with the children’s father,’ and he said, ‘Not him. Only you and your children,'” Tania recalled.

Despite the family’s protests, the agent insisted on sending one parent back to Juárez and asked Sofi which parent she wanted to go with, Tania recalled.

But the doctor, whose name the family doesn’t recall, stayed late Thursday to prevent the separation and returned Friday morning to plead his case to another agent.

“He explained to the other officer that they all have to enter as a family. It was the morning shift officer. He replied, yes, he was going to give him [Joseph] entrance,” Tania said.

The family was released Friday to an El Paso migrant shelter and flew to join relatives in the Midwest on Sunday, according to NPR.

The Department of Homeland Security didn’t respond to NPR’s questions about the family’s treatment.