A 19-year-old Salvadoran national — arrested in Maryland last week on charges that he brought an AR-15 assault-style rifle into a high school parking lot — was released from the Montgomery County jail despite a request that he be held for possible deportation proceedings, officials said Monday.

The suspect — Mario Granados Alvarado, a high school student also believed to have been driving a stolen car — was found the day after his release from the county jail and arrested by Immigration and Customs Enforcement agents, authorities said. The process created needless risk, federal officials said.

“Keeping people safe means not tolerating the release of aliens that present a clear public safety threat back into our communities,” said Dorothy Herrera-Niles, a Maryland field office director of ICE’s Enforcement and Removal Operations unit.

The use of immigration detainers has been contentious between ICE and Montgomery County. ICE uses detainers to request that jails hold suspects for up to 48 hours after they post bond, giving agents time to take people into custody if there is a potential immigration issue.

Patrick Lacefield, a spokesman for Montgomery County Executive Isiah Leggett (D), said that the county has abided by detainers in serious, violent cases, but that it has declined to accept detainers from ICE for other cases as the county tries to balance public safety and building strong relationships with immigrant communities.

Mario Granados Alvarado (Montgomery County Police Department)

On Monday, Montgomery officials said they should not have released Granados Alvarado.

“It was a mistake and we should have honored the detainer,” said Robert Green, director of the Montgomery County Department of Correction and Rehabilitation. “It is the county’s intent to honor ICE detainers on serious charges.”

Matthew Bourke, an ICE spokesman, said Granados Alvarado’s actual arrest went smoothly. “It was a standard arrest. He was found at a registered address,” Bourke said. “But one of the reasons we issue detainers is to make an arrest in a secure, safe environment, and a street arrest presents much uncertainty.”

Granados Alvarado illegally entered the country about three years ago, according to federal officials. On March 6, 2014, he was picked up by U.S. Border Patrol agents in Texas. He was issued a notice to appear in immigration court and is currently in removal proceedings, Bourke said.

He had been living in Montgomery since about that time, according to Montgomery District Court records.

He was arrested at least twice — on May 27, 2016, after he allegedly stole $226 worth of clothes from a JC Penneys in Wheaton, and on April 17 on suspicion of car theft in Baltimore County. He spent two days in jail in Baltimore County before he was released on $5,000 bond. The Baltimore case is pending. The earlier theft case was dropped. Online records do not say why.

On May 1, a police officer assigned to Albert Einstein High School, in Kensington, grew suspicious after seeing a student get out of a blue Mazda, walk into the school carrying a small grocery bag and walk out without the bag, authorities said. The officer followed the Mazda as it drove away and pulled it over.

The driver got out, said “I scared” several times, and ran off, said Officer Rick Goodale, a police spokesman.

Because the driver hadn’t done anything noticeably illegal, the officer didn’t chase him, Goodale said, but he did run a check on the license plate and learned that the car had been reported stolen. The driver returned and was taken into custody.

Inside the car, police found a Colt AR-15 assault-style weapon, five fully loaded magazines and two unloaded magazines, according to court records. The gun and ammunition had been stolen from a Rockville City Police car, police said.

Granados Alvarado was charged with car theft, carrying a dangerous weapon on school property and other counts. At no point, Goodale said said Officer Rick Goodale, a police spokesman, was the gun believed to have been taken inside the school.

On May 2, a court commissioner set Granados Alvarado’s bond at $50,000, according to court records. That same day, ICE lodged the detainer, Bourke said.

Also that day, a District Court judge lowered Granados Alvarado’s bond to $2,000. He posted it the following day and was released.