An eight-year-old Haitian boy detained by immigration agents in San Diego on 4 November and transferred to a facility in Texas has been released from Immigration and Customs Enforcement (ICE) custody and reunited with his family in California.

Representative Juan Vargas shared a photograph of the boy with his family in a social media post on Monday. “11 days ago, an 8-year-old in San Diego was taken into federal custody during an immigration check-in. He was separated from his loved ones and held in a facility in Texas. Today, he’s finally home.”

The Haitian Bridge Alliance, an immigration advocacy group, confirmed the third-grader’s release. Its executive director, Guerline Jozef, said: “An eight-year-old child belongs in a classroom, on a playground, and surrounded by love – not in immigration detention. We welcome his release, but his freedom should never have required a public outcry.”

The boy, a third-grader at Fay elementary school, was put in restraints and taken into custody during a check-in earlier in the month, according to video obtained by NBC News and an oversight letter sent by Democratic lawmakers to the Departments of Homeland Security and Health and Human Services.

A spokesperson for the Department of Homeland Security said ICE took the child into custody “out of an abundance of caution and to ensure the child’s safety”. In a statement to the Guardian, the spokesperson said the boy’s uncle could not prove legal guardianship and officials were obliged under federal anti-trafficking laws to take him into care as an “unaccompanied alien child”.

The Haitian Bridge Alliance said the boy had been in the care of his uncle and cousins after his father was deported last year.

Vargas said in a second social media post: “I’m so grateful that he’s home, but this should have never happened in the first place.” He added that he would ask the Trump administration for answers. While detained, the child was “held in a facility in Texas, far away from his home in San Diego”, Vargas said.

Jozef told NBC News: “The aunt was literally crying, and she said: ‘I have not eaten since the Wednesday they took my baby.’ They haven’t been able to sleep because of that.” She added: “The cousins were there when they took him, and wondering: will they ever see him again? But today [Monday] they are able to see him again. They are able to hug him.”