Data shows that students of color are disproportionately arrested at school, and advocates and educators contend that schools will increasingly rely on law enforcement to manage disciplinary issues if the guidance is rescinded.

In Houston, Mr. Rivera-Sarmiento’s run-in with the law still divides the community.

Some remain convinced that Mr. Rivera-Sarmiento’s status does not exempt him from criminal and immigration laws. Others believe the district unfairly subjected him to them.

Mr. Rivera-Sarmiento said he was arrested at his school after he defended himself against an attack from a schoolmate. She had teased him incessantly, he and his lawyer said, on this day calling him a “wetback” before throwing a bottle of Gatorade at him.

He pushed her down on the ground before running across the street to flee the area. When he returned to the school’s campus a few minutes later, he approached the school police officer to report what had happened. He was hoping for help, he said, but was escorted to the principal’s office in handcuffs. He was charged with misdemeanor assault.

The officer took him to the county jail, run by the Harris County Sheriff’s Office, which is required by state law to cooperate with immigration enforcement. There, he was flagged during booking proceedings as being in the country illegally. Mr. Rivera-Sarmiento, who came to the United States in 2013, had a pending deportation order.

As Mr. Rivera-Sarmiento bounced around three detention centers, students, teachers and advocates held demonstrations, circulated petitions and had fund-raisers to protest his detainment. Mr. Rivera-Sarmiento’s plight even caught the attention of Hollywood, where the actress Alyssa Milano signed and publicized a petition with the hashtag #FreeDennis.