The Virginia attorney general's race is looking like one of the closest in recent history, with 99.9 percent of the vote in and just 144 votes separating the two candidates out of about 2.2 million cast.

Republican Mark Obenshain leads by that margin over Democrat Mark Herring. Just one precinct has yet to report -- in Prince William County, which Herring is winning with 54 percent of the vote.

Here's the lowdown on the likely legal battle ahead:

State election law provides for the trailing candidate to request a recount if the margin of victory is less than 1 percent of the total vote. Both campaigns said they were preparing to do so if they ended up on the losing end of the final count.

The margin in this race is actually slightly closer than it was in the hard-fought Minnesota Senate race in 2008. In that race, Republican Sen. Norm Coleman led by 725 votes on election night but wound up losing by 312 votes after eight months of legal battles.

In that case, Democrat Al Franken took the lead in the weeks after Election Day, and Republicans fought tooth and nail to prevent him from becoming the 60th Democratic vote in the Senate -- a point at which Democrats could override any GOP filibusters.

The stakes in the Virginia attorney general's race, of course, aren't nearly that high. But that doesn't mean there won't be a legal battle. If Herring manages to win, Democrats will control every statewide office in Virginia for the first time in decades.