Virginia Attorney General Mark R. Herring will announce Thursday that he believes the state’s ban on same-sex marriage is unconstitutional and that Virginia will join two same-sex couples in asking a federal court to strike it down, according to an official close to the attorney general with knowledge about the decision.

The action will mark a stunning reversal in the state’s legal position on same-sex marriage and is a result of November elections in which Democrats swept the state’s top offices. Herring’s predecessor, Republican Ken Cuccinelli II, adamantly opposes gay marriage and had vowed to defend Virginia’s constitutional amendment banning such unions, which was passed in 2006 with the support of 57 percent of voters.

Herring, too, had voted against same-sex marriage eight years ago, when he was a state senator. But he has said that his views have changed since then and that on Thursday he will file a supportive brief in a lawsuit in Norfolk that challenges the state’s ban, said two people familiar with his plans.

Herring will say that Virginia has been on the “wrong side” of landmark legal battles involving school desegregation, interracial marriage and single-sex education at the Virginia Military Institute, one official said. He will make the case that the commonwealth should be on the “right side of the law and history” in the battle over same-sex marriage.

He has not informed Republicans in Richmond about his plans; an uproar is likely. GOP lawmakers have worried that Herring would change the state’s position — such decisions are up to the attorney general — and have contemplated legislation that would allow them to defend the law in court.

The attorney general thinks that is unnecessary, the official said. The clerks of the circuit court in Norfolk and Prince William County are defendants in the suit, and both are represented by independent counsel.

Janet Rainey, the state registrar of vital records, is also a defendant. Although she and Herring will urge the court to strike down the ban, she will continue to enforce it until the courts act.

The move in Virginia is part of a quickly changing legal landscape reshaped by the Supreme Court’s rulings in two cases on same-sex marriage in June.

In one, U.S. v. Windsor, the court voted 5 to 4 to find unconstitutional a key part of the Defense of Marriage Act, which withheld federal recognition of same-sex marriages performed where they are legal and denied federal benefits to those in such unions.

In the other, it allowed to stand a federal judge’s opinion that California’s Proposition 8, which bans same-sex marriage, was unconstitutional. The court ruled that the case was not before it in a way that allowed a ruling on the merits.

The justices sidestepped a critical question: whether state bans on same-sex marriage violate the Constitution’s guarantees of equal protection and due process.

But federal judges in Utah and Oklahoma have said that the reasoning used by the court majority meant that constitutional amendments in those states banning same-sex unions cannot stand. Gay marriages took place in Utah, but both decisions are now stayed pending appeal.

The highest courts in New Jersey and New Mexico have held that gay couples have the right to be married there. The District of Columbia and 17 states — including Maryland but not counting Utah and Oklahoma — now allow such unions.

The Obama administration took a position similar to Herring’s when it announced it would not defend DOMA, which Congress passed in 1996 and President Bill Clinton signed into law. Attorney General Eric H. Holder Jr. joined the legal challenge against the key part of the law, and House Republicans hired a lawyer in an unsuccessful bid to save it.

Similarly, Democratic attorneys general in other states have said they think their bans are unconstitutional. Democrats in California refused to defend Proposition 8. And last summer, Pennsylvania Attorney General Kathleen Kane bowed out of challenges to her state’s law.

Herring, whose race against Republican Mark D. Obenshain was so close it was not decided until Dec. 18, has been in office just two weeks. But he faced a tight deadline in deciding whether to change the state’s legal position.

U.S. District Judge Arenda L. Wright Allen has scheduled oral arguments for Jan. 30 in the Norfolk case. It received a jolt of attention last fall when lawyers Theodore B. Olson and David Boies, who brought the federal challenge of Proposition 8, announced that they were joining the plaintiffs’ side.

In addition, the American Civil Liberties Union is challenging the Virginia ban in a federal suit in Harrisonburg. That case is not as far along.

Virginia has been a particularly appealing place for a challenge by supporters of gay rights because of the Supreme Court’s 1967 decision in Loving v. Virginia, which struck down laws against interracial marriage. Those who support same-sex unions often draw a parallel.

Herring will make the same point, according to a person who has seen the brief he will file. The state will say that Loving upheld the fundamental right to marriage, not the right to interracial marriage. The question at stake now, the brief states, is not a right to same-sex marriage but whether the fundamental right to marriage can be denied to “loving couples based solely on their sexual orientation.”

Democrats are sensitive to charges that it is Herring’s duty to defend Virginia’s law regardless of whether he agrees with it. They point out that Cuccinelli refused to defend one of then-Gov. Robert F. McDonnell’s education reforms in court, saying he believed that the legislation (for state takeovers of failing schools) was unconstitutional.

Herring also will say that the state’s law will be defended in the Norfolk challenge. Norfolk clerk George E. Schaefer is represented by a private lawyer paid by the state’s Department of Risk Management. Prince William clerk Michèle B. McQuigg, who asked to intervene in the case, is represented by the conservative legal group Alliance Defending Freedom.