A 42-year-old illegal immigrant who allegedly had sex with a 19-year-old special-needs student at a Brooklyn Park high school was taken into custody Friday night by federal immigration agents, an immigration official said Saturday.

The suspect was detained after being released from the Hennepin County jail Friday afternoon. His jail release came after prosecutors delayed criminal charges as police continue to investigate the incident, which occurred Wednesday at Champlin Park High School.

Brooklyn Park police knew the suspect was undocumented when he was booked into jail, Deputy Chief Mark Bruley said. Immigration and Customs Enforcement was alerted during the booking and took the man into custody after his release, ICE spokesman Shawn Neudauer said Saturday.

The agency placed a detainer on the man, meaning officers can question him regarding suspected immigration violations. ICE places such detainers only on people they believe to be deportable, Neudauer said.

Earlier, police said the man had a Washington state driver's license and travels around the country. It was not clear Saturday whether that license was valid.

The student met the man through a dating app and had arranged to meet at Champlin Park High School on Wednesday, police say. He bypassed the school office, which is a separate house on campus, entered the school and met the student in a bathroom, where they engaged in sex. The two later returned to the same bathroom to have sex again. The suspect was on campus for about 55 minutes, according to police.

Students noticed the man acting suspiciously about noon and contacted school officials, who approached him. He tried to flee but was held by a security guard, a teacher and staff until police arrived.

The Anoka-Hennepin School District upped security measures after the breach.