The nation’s second-largest school moved Tuesday to end random metal-detector searches of students at secondary schools, a daily procedure that critics called ineffective, intrusive and offensive.

The board of the Los Angeles Unified School District directed Superintendent Austin Beutner to develop an alternative plan for school safety that eliminates the use of random searches by July 2020.

“Administrative random searches are incredibly invasive, dehumanizing and communicate to students that they are viewed not as promising minds but as criminals,” board member Tyler Okeke said.

The daily searches were instituted in 1993 in the wake of several mass shootings at schools around the country and a perceived increase in violence involving firearms and other weapons on campuses.

They involved random students being checked with hand-held metal detector wands.

Critics, however, said the searches weren’t really random but disproportionately targeted blacks and other minorities. Dozens of speakers opposed the searches at the board meeting.

“You don’t have to people feel like criminals in order to keep our schools safe,” said David Turner of the Brothers, Sons, Selves Coalition. “Our young people need love, our young people need protection, they do not need to be treated as if they are the problem.”

Some board members dissented.

“A fair, nondiscriminatory, and respectful wanding program provides increased safety for students and staff,” Scott M. Schmerelson said. “It may not be the perfect tool, but until a reasonable and effective alternative is proposed, I sincerely believe that random wanding serves as a deterrent for students who may consider bringing a weapon to school.”

A coalition called Students Not Suspects issued a report last year that concluded the random searches didn’t turn up any guns and only a tiny fraction of them produced any weapons at all. The report said the searches also pulled students out of class and cost the district more than $1 million a year.

The school district has more than 730,000 students and more than 1,000 schools.