The State Capitol building in Richmond,Va. (Marvin Joseph/The Washington Post)

Legislation that would allow Virginia parents to prevent their children from reading sexually explicit materials in school cleared its final hurdle Thursday in the General Assembly and was sent Gov. Terry McAuliffe’s desk.

The governor has given no public hint as to whether he will veto or sign the bill.

House Democrats last month voted unanimously in favor of the bill in a block of uncontested bills, but many of them switched their votes Thursday after opponents said it could open the door to book banning.

The House voted 77 to 21, with the support of 20 Democrats and one Republican who voted against the bill in error.

“We can all makes mistakes, like I think we all did when we first voted for this bill unanimously,” Alfonso H. Lopez (D-Arlington) said on behalf of Democrats.

The legislation was prompted by a Fairfax County mother who objected to her son, then a high school senior, reading Toni Morrison’s “Beloved” in his Advanced Placement English class. She cited “The Bluest Eye,” also by Morrison; “Invisible Man” by Ralph Ellison; and “The Road” by Cormac McCarthy as books that she said are also inappropriate for students.

The bill would make Virginia the first state in the nation to require K-12 teachers to notify parents of classroom materials with “sexually explicit content.” Parents could then “opt out” their children and request that the teacher provide an alternative assignment.

About half of Virginia school districts already follow this practice, but lawmakers who support the bill said it should be state law.

David B. Albo (R-Fairfax) acknowledged that Morrison, a Nobel laureate, is one of the country’s seminal authors, but said he was offended by a passage in one of her books.

“I lived in a fraternity house for two years,” he said. “There’s not very much stuff that offends me, and even I was aghast at how bad it was.”

Del. R. Steven Landes (R-Augusta), who sponsored the legislation at the request of House Speaker William J. Howell (R-Stafford), said the bill does not censor or ban books.

But Lopez said teachers might shy away from teaching books with sexual content if they have to produce a second lesson plan for students reading alternative material. For that reason, he called the bill a “slippery slope to back door censorship.”

“When the government establishes laws to label literature in terms of a single factor … it edges closer to censorship,” he said during a speech on the House floor. “It means we are labeling content for the sole purpose of potentially suppressing it.”

The National Council of Teachers of English and National Coalition Against Censorship oppose the bill; the Family Foundation of Virginia favors it.