Mark Obenshain campaigns Monday in Warrenton. (Nikki Kahn/The Washington Post)

Virginians may be in for a long wait, possibly into December, to learn who will become their next attorney general, the official who serves as the commonwealth’s top lawyer in such a prominent office that it has become a springboard to the governor’s mansion.

In fact, “AG” has come to stand for “almost governor” in state politics.

State Sen. Mark D. Obenshain (R-Harrisonburg) held a 727-vote lead over state Sen. Mark R. Herring (D-Loudoun) on Wednesday evening, according to the Virginia State Board of Elections. More than 2 million votes were cast in the race.

The margin widened and narrowed throughout the day, as local election boards began reviewing Tuesday’s vote. Boards spent the day processing provisional ballots, votes cast by individuals who didn’t have proper ID at the polls or who went to the wrong polling place. They also began to canvass returns, combing through them for human and mechanical errors.

The boards have until Tuesday to certify their returns as accurate and submit them to the state. The Virginia State Board of Elections is scheduled to certify all returns Nov. 25. After that, the trailing candidate may request a recount.

Kyle Kondik of Sabato's Crystal Ball talks with PostTV’s Nia-Malika Henderson about how Virginia's demographics may be changing too quickly for it to remain a national political bellwether. (The Washington Post)

Both campaigns dispatched observers Wednesday to monitor canvassing. They said they would let the process play out and expressed confidence they would ultimately win.

“Since polls closed, we’ve seen several lead changes, and based on our projections, we are going to win,” Herring campaign manager Kevin O’Holleran said in a statement. “When all of the votes cast are counted, including absentee votes and thousands of provisional ballots, we’re confident Mark Herring will be the next attorney general of Virginia. We have a responsibility to make sure that every voter is protected and every vote counts.”

Obenshain said in a statement: “Right now, the race is extremely close, but I’m confident that we will prevail.”

Veterans of recounts said the next 48 hours were critical for the campaigns because major errors swinging a race are usually uncovered within that window.

“They want to have eyes and ears out there as they canvass the precincts. If they are going to lose net votes, they want to know why,” said lawyer Chris Ashby, a former senior staff member for then-Del. Robert F. McDonnell’s 2005 campaign for attorney general, which ended in a recount.

It was Dec. 21 before a judicial panel declared McDonnell the winner by 360 votes over Democratic state Sen. R. Creigh Deeds.

State law allows the trailing candidate to ask for a recount if the certified vote shows a margin within 1 percent of total votes cast. The candidate must pay for the recount unless the margin is less than half a percent.

Ashby said it is “certainly possible” that Herring or Obershain could end the canvass within the 1 percent margin but decide that it was still too many votes to make up.

In 2006, the outcome of the Virginia U.S. Senate race was in doubt as George Allen considered whether to contest James Webb’s narrow victory. Although Webb’s 7,300 vote gap was within the required margin, Allen rejected the idea of a recount.

The attorney general is the state’s chief lawyer and litigator, heading a virtual firm of more than 130 lawyers. The attorney general provides legal advice and opinions to the governor and all state agencies and defends the constitutionality of Virginia laws.

Attorney generals can take center stage in big national legal controversies. In 2010, Ken Cuccinelli II (R), who lost Tuesday’s gubernatorial race to Democrat Terry McAuliffe, became the first attorney general to file a lawsuit challenging the new federal health-care law. The suit was later thrown out by the U.S. Court of Appeals, which ruled that Virginia lacked standing to sue.

Attorney generals also invariably find themselves on the short list for gubernatorial contests. Since 1985, six Virginia attorneys general have resigned before the end of their terms to launch gubernatorial campaigns. Cuccinelli ran but did not resign. Three went on to win: Republicans McDonnell and James S. Gilmore and Democrat Gerald L. Baliles.

But, as Cuccinelli discovered, the job is not a guaranteed ticket to the governor’s mansion.

“It gets you a nomination but not always a governorship,” said Republican Jerry Kilgore, one of the attorneys general who lost the race for the higher office.