Asserting that Virginia had too often been on the “wrong side” of justice on civil rights matters, the state attorney general asked a federal court on Thursday to invalidate the state’s ban on same-sex marriage, calling the law unconstitutional and oppressive.

The move by the attorney general, Mark R. Herring, a Democrat who took office this month, was the first indication of how consequential last November’s elections in Virginia, in which Democrats won all three top elected positions from Republicans, may turn out to be. Mr. Herring, a former state senator, narrowly defeated Mark Obenshain, a Republican state senator.

The decision to drop support for the gay marriage ban was an abrupt shift from the positions taken in the past by the state’s socially conservative elected officials, and put Virginia on a path to be the first Southern state to allow same-sex marriage. Republican officials swiftly denounced the decision, calling for Mr. Herring’s resignation.

At a news conference in Richmond, Mr. Herring said the ban violated the 14th Amendment right to due process and equal protection, an argument that has been the basis of successful legal challenges to same-sex marriage prohibitions in other states.