Virginia lawmakers on Monday sent legislation to Gov. Terry McAuliffe that would create a new legal defense for juveniles with special needs who are charged with committing misdemeanor offenses in school.

Supporters say the bill is intended to more fairly apply the law to minors with autism and attention deficit hyperactivity disorder, among other diagnoses, and keep them out of the juvenile justice system.

Opponents, including the Virginia Association of Commonwealth’s Attorneys, say the bill would apply not just to students with intellectual disabilities, but to anyone with difficulties such as dyslexia, a speech impediment or blindness. They also note that the legislation would not shield such youths from the justice system entirely, although it could bolster their defense by allowing them to present evidence of their disability during a trial.

The bill comes on the heels of a Center for Public Integrity report that found that Virginia schools refer more students to law enforcement agencies than any other state. Nationally, it found that special-needs and African American students are disproportionately referred to police.

On Monday the bill passed the House with just one vote against it by Del. R. Lee Ware Jr. (R-Powhatan). Only Sen. R. Creigh Deeds (D-Bath) voted no when it cleared the Senate last week. A spokesman for the governor, Brian Coy, would not say whether McAuliffe (D) would veto, amend or sign the bill into law.

The bill allows minors charged with misdemeanors to present at trial a special-needs education plan created to address a disability as evidence that they were of “diminished capacity” and should not be found guilty.

“A kid with some kind of a disability may know that he’s not supposed to throw the trash can across the room, but he just can’t help himself,” Del. David B. Albo (R-Fairfax), the sponsor of the legislation, said in a floor speech.

He added that prosecutors oppose the bill but “they created this problem themselves because they shouldn’t ever have been prosecuting these kids.”

Lori Digiosia, a deputy commonwealth’s attorney in Stafford who spoke in an interview on behalf of the Virginia Association of Commonwealth’s Attorneys, disagreed.

“Virginia’s prosecutors — we do not want to see kids in criminal court on disorderly conduct charges when they have a disability and that disability is the root cause of that criminal behavior,” she said.

She said that instead of waiting until trial to present the special-needs education plan, schools, school resource officers and juvenile court intake officers should be aware of the situation before the minor is charged with a crime. Currently, the juvenile court judge can use the plan during the sentencing phase of the case.

“They are trying to address this problem at the wrong end of it,” Digiosia said of the bill.

Juliet Hiznay, an Arlington-based special-education advocate and attorney who favors the legislation, said that entering the special-needs education plan during sentencing doesn’t help.

“People are seeing children being charged and placed on probation for long periods of time — house arrest, juvenile detention,” Hiznay said. “We need to do a better job of keeping these kids out of the juvenile justice system.”

Prosecutors call the bill a “wholesale change,” but Hiznay said it is an incremental step in addressing problems revealed by the Center for Public Integrity report on juvenile justice.

“It’s a good idea, because children with disabilities are being charged under Virginia law for behavior that is directly related to their disability that they don’t have any control over, and it’s not being recognized by prosecutors,” she said.

Del. Richard “Rip” Sullivan (D-McLean) voted for the bill, but he said that he worried the special-needs education plans could be used for cases in which the disability played no role.

“You have to be careful of the proverbial slippery slope,” he said.