Local school boards have the authority to include sexual orientation and gender identity in their anti-discrimination policies, Attorney General Mark R. Herring declared in an official opinion issued Wednesday.

“Every Virginian has the right to live, learn, and work without fear of discrimination,” Herring (D) said in a written statement. “That’s a Virginia value, and one that we must guard even more carefully when it comes to our children.

The opinion, which reverses one issued in 2002 by Jerry Kilgore (R), then the attorney general, is likely to further raise Herring’s profile on gay-rights issues and perhaps boost his prospects with Democratic primary voters if he runs for governor, as expected, in 2017. Herring was already a hero to gay-rights activists and a lightning rod for conservatives after refusing to defend the state’s ban on same-sex marriage last year.

While written more than a decade apart, Herring’s and Kilgore’s opinions were both triggered by the Fairfax County School Board. Back in 2002, the board sought Kilgore’s opinion as it considered providing protections concerning sexual orientation.

It was deterred by Kilgore’s response, which said the Fairfax officials did not have the legal authority under the Dillon rule to amend its policies concerning sexual orientation. The Dillon rule limits local government bodies from creating policies where a state statute does not exist.

“It is my opinion that, without enabling legislation, the Fairfax County School Board has no authority to include sexual orientation in its nondiscrimination policy,” Kilgore wrote at the time.

In November, noting that in October the U.S. Supreme Court let stand rulings that allow gay marriage in Virginia, the Fairfax board approved a new nondiscrimination policy that included protections for sexual orientation.

“The Supreme Court of Virginia has been clear that our constitution allows school boards to regulate for the ‘safety and welfare’ of children, and the General Assembly has been clear that school boards shall ‘provide that public education be conducted in an atmosphere free of disruption and threat to persons or property and supportive of individual rights,’ ” Herring said in his statement. “The law and the precedents are clear.”

Herring issued the opinion at the request of state Sen. Adam Ebbin (D-Alexandria), who said he hopes other Virginia school boards will follow the lead of Fairfax, as well as Arlington and Alexandria City public schools, which have had policies protecting sexual orientation for several years.

“It was just recently that Fairfax did it, and it seemed like there had been some hesitation in past years for other boards,” Ebbin said. “I’m glad that the attorney general took a fresh look at this,” he added. “It shouldn’t be controversial from a legal or policy perspective.”

Herring’s opinion quickly drew rebukes from conservatives. State Sen. Richard H. Black (R-Loudoun) said Herring was catering to “radical elements” and had overstepped his authority.

And Chris Freund, spokesman for the Family Foundation of Virginia, said: “The attorney general has once again placed his desperate desire to be the Democrat nominee for governor over the longstanding policy and law of Virginia. In doing so he has put at risk the welfare of students who have deeply held religious beliefs about human sexuality that a teacher or administrator could deem ‘discriminatory’ and single out for punishment.”