Francisco Erwin Galicia, 18, an American who was held in immigration custody for almost a month, was released Tuesday afternoon.

“I’m so thankful Francisco is free and he can sleep at home tonight and see his mom,” Claudia Galan, Galicia’s attorney, told The Associated Press.

Galicia, a high school senior, his brother, and a few friends were heading to a college soccer team tryout on June 27 when their car was stopped at a Border Patrol checkpoint in Falfurrias, Texas. Border agents asked for papers, and Galicia provided a wallet-sized version of his Texas birth certificate, Texas ID card and Social Security card. U.S. Customs and Enforcement officials detained him anyway, claiming that the documents could be fake. “He’s been here all his life,” Galan told The Washington Post. But, she said, “When Border Patrol checked his documents, they just didn’t believe they were real. They kept telling him they were fake.”

Galicia was “one of hundreds of American citizens in recent years who, mistakenly targeted by federal immigration authorities, have been forced to prove their citizenship while the threat of deportation hangs over their head,” the Post writes. The Los Angeles Times reported last year that since 2012, ICE has had to release 1,480 people from custody because it turned out they were in fact American citizens.

Galan told the Associated Press that her client was “absolutely” a victim of racial profiling, given that all the occupants of the car were Latinx.

The Post suggests that ICE may not have been able to differentiate between the people in the car who did have legal status, and those who did not. Galicia’s brother, Marlon, does not have legal status, but told the Dallas Morning News that he previously passed Border Patrol checkpoints on school trips with no problems. When he was asked to show travel documents in June, Marlon only had a Texas ID. He was voluntary deported and spoke to the News from Reynosa, Mexico, where he is staying with his grandmother.

“We were confident that we’d be able to pass. We were going to do something good for our futures,” he told the News. “I didn’t imagine this could happen, and now I’m so sad that I’m not with my family.”

The Post reports that Francisco “languished for weeks” in a Customs and Border Patrol facility before being moved to an ICE facility in Pearsall, Texas, where he was finally able to make collect calls to his mother. Complicating his situation was the fact that Galicia’s mother (who is not a U.S. citizen) once took out a tourist visa for him, which erroneously said that he was born in Mexico, Galan said. The Post explains that his mother “took out the tourist visa for her son because she saw it as the only way he could travel back and forth across the border to visit family.”

The Dallas Morning News report got the attention of elected officials, including New York Rep. Alexandria Ocasio-Cortez, who tweeted:

CBP is detaining *American citizens.* How would you feel trapped in a border camp, where guards wear face masks because the human odor is so strong? When we allow the rights of some to be violated, the rights of all are not far behind. https://t.co/U4NFQtv8F3 — Alexandria Ocasio-Cortez (@AOC) July 23, 2019

Sanjuana Galicia, Francisco’s mother, told the Dallas Morning News that ICE informed her Tuesday afternoon that they had determined Francisco’s documents were valid. “The first thing he said to me was, ‘Mommy, they let me go. I’m free,’ ” Sanjuana said.

Neither ICE nor Customs and Border Patrol responded to the Morning News’ requests for comments on the release. Marlon remains in Mexico.