This year's Fredericksburg Fair had the usual attractions: Hercula the Giant Horse and Black Jack the Giant Steer, the carnival rides and the four-wheeler races. But added to the mix was something Virginians had not seen for decades -- the earnest campaigning of a competitive presidential race.

As the Friday-night crowds entered the fairgrounds in a part of the state on the dividing line between its liberal north and conservative south, volunteers for Sen. Barack Obama's campaign set up post to register voters. "It's time for a change," said one volunteer, Josef Jazvic, 39, an information technology worker helping on a campaign for the first time. "The fact that [Virginia] is even up for grabs tells you a lot."

Virginia hasn't voted for a Democratic presidential candidate since 1964, and President Bush carried the state twice, by nine and eight points. But the campaigns of Obama and his Republican opponent, Sen. John McCain, agree that it has become one of the nation's new swing states, joining the likes of Ohio, Florida and other battlegrounds in determining who will win the White House. The result in the Old Dominion has been a burst of political activity unlike any in modern times.

In early June, after clinching his party's nomination, Obama held his first big rally in Prince William County, the state's second most populous county and one that is critical to his chances of winning Virginia. He has since opened more than two dozen campaign offices across the state and says he has 10,000 volunteers working to deliver its 13 electoral votes.

McCain's national headquarters is in Arlington, and his campaign is trying to mobilize a conservative core that other Republicans have been able to take for granted. Both candidates are seriously considering Virginians as their running mates, perhaps the clearest sign yet that the state has presidential cachet.

"If you had told me four years ago that a Democratic presidential candidate would be running a competitive race in Virginia and would open 10 offices, I would say that is spectacular," said Gov. Timothy M. Kaine, a leading contender to be Obama's running mate. "Now we have a guy who has opened 20 to 30 offices around the state? You've got to be kidding me."

The Obama campaign believes it can win by duplicating the success of Kaine, Sen. James Webb and former governor Mark R. Warner, who have led a Democratic revival in Virginia that would be complete with a win on the presidential level. The campaign hopes to capitalize on Bush's lack of popularity, the changing demographics in Northern Virginia, high turnout -- particularly among younger voters and African Americans -- and a volunteer base that delivered a big win in the Democratic primary in February.

Virginia Republicans acknowledge that the state has become more competitive but predict that it remains inherently conservative, particularly when it comes to national security and other issues at stake in a presidential race.

"We have traditionally been the party who can get their people to the polls when it's a presidential race," said Jerry Kilgore, a former state attorney general from southwest Virginia who lost to Kaine in 2005. "Even in 1996, when [Bill] Clinton was winning every state imaginable, Bob Dole won Virginia because our people showed up."

Both campaigns have been running television ads in the state for weeks, but on the ground the battle is emerging as a contrast in approaches. In keeping with his strategy throughout the primaries, Obama has invested heavily in field operations, opening 28 offices -- including one in tiny Castlewood, in the farthest southwest corner -- and deploying dozens of paid staffers and "fellows," volunteers recruited from around the country.

His campaign is also relying on native Virginian volunteers -- delegating team leaders in each of the state's 2,600 precincts and encouraging them to organize events, all of which are advertised on the interactive "My Barack Obama" portion of the campaign's Web site.

In Northern Virginia the week of July 21, volunteers ran a nightly phone bank out of offices in Arlington and McLean. They also registered voters at Wolf Trap concerts, movie theaters, grocery stores and a farmer's market. They sent out hundreds of canvassers in the evenings and on weekends, held a house party in Fairfax for the Jewish community, and held issue discussions at restaurants in Arlington and Alexandria.

As volunteer-driven as the campaign is, though, Obama's state leadership in Richmond is asserting closer oversight over voter outreach than did recent Democratic presidential campaigns, which often found themselves duplicating the efforts of those working on their behalf. It plugs all voter contacts into a big database and often deploys a staff member to monitor even small-scale events.

For the past month, much of the Obama campaign's focus has been on registering voters. Virginia has recorded 147,000 new registrations this year -- it does not register by party -- and the campaign's goal is 150,000 more. It estimates that if 80 percent of those new registrants are for Obama, and that if 75 percent show up at the polls, that will mean a gain of more than 60,000 votes -- or an extra 1.75 percent, assuming turnout is around 3.5 million.

To further close the gap, the campaign is targeting what it calls "sporadic" Democrats -- potential supporters who missed at least one recent statewide race and may need a nudge to turn out for Obama -- plus moderate Republicans and independents who may be tempted to cross over. To reach this second group, the campaign is using "micro-targeting" techniques popularized by the 2004 Bush campaign, divining voters' leanings through consumer preferences or other hints.

"For a race that's going to be as close as this is, it will take a lot of pieces of the puzzle for us to add to be successful," said Virginia campaign director Mitch Stewart, a South Dakota native who helped run Obama's primary campaigns in states including Iowa and Indiana.

For the McCain campaign, the challenge is holding on to as much of Bush's 2004 advantage as possible, particularly by trying to win back voters who favored the president but also voted for Warner, Kaine or Webb. It is being undertaken with a ground operation more limited in scope and more hierarchical than Obama's. The campaign, which as elsewhere is working in close concert with the Republican National Committee, has opened six offices statewide, with three more on the way, on the theory that Obama's greater visibility is mostly for show and not worth the cost to match.

Its volunteer efforts are directed out of campaign headquarters and are organized into clearly delineated coalitions, such as veterans, sportsmen, social conservatives and young Republicans. On weekday evenings, 30 or so people from one of the groups take over the phones in McCain's offices in Crystal City, where both his national and Virginia headquarters are based.

"We run a very disciplined, methodical, structured organization," said Trey Walker, McCain's Mid-Atlantic director. "We are doing exactly what Republican campaigns have done in the past."

What is different, Walker said, is that because Virginia has become a haven for Republicans, the party does not have close to the presidential-campaign structure that it has in standard swing states such as Ohio, where "all they have to do is add water every four years."

"We've got to get to a level of organization that really hasn't been done before here," he said.

J. Kenneth Klinge, a Republican strategist in Fairfax County, said he is encouraged to see his party trying to rebuild its grass roots. What worries him is Obama's effort to register new voters.

"It is no doubt they are going to register anything that can walk, talk and chew gum at the same time, so that will give them an advantage," he said. "Anyone who they have registered, they will then go grab them by the back of the scruff and take them out to vote."

The lines of engagement are clear across the state's highly variegated landscape. To win, Obama must rack up big numbers in populous Northern Virginia, which has become increasingly Democratic as it has boomed over the past decade.

In 2004, John F. Kerry managed to win Fairfax County, where one in seven Virginians lives. Obama wants to increase his margins there and in the Democratic strongholds of Arlington and Alexandria, while also claiming the outer suburbs of Loudoun and Prince William counties, which Webb and Kaine won but Kerry lost. Obama swept the region in the state's primary.

Republicans are not ceding the region. The national party has paired Walker with Nick Meads, the former campaign manager for Rep. Tom Davis (R-Va.), who will be helpful in identifying Republican-leaning voters in Northern Virginia. Del. David Albo (R) said that his southern Fairfax district still leans Republican and that McCain can carry it, which would make it hard for Obama to reach 60 percent in the county, as Kaine and Webb did.

Greg Werkheiser, a Democratic activist who ran against Albo in 2005 and helps head up Obama's efforts in that part of Fairfax, counters that the district is solidly behind the Democrat.

"I would say eight in 10 doors we go to are either strong, self-identified Democrats who are for Obama or frustrated moderate Republicans who don't believe McCain represents change from Bush," he said.

Obama will also seek to win big in Richmond and try to split the vote in its suburbs, which Kaine did in 2005. Though Bush won Chesterfield County with 63 percent of the vote in 2004, the county ran out of ballots during February's Democratic primary because so many voters turned out.

Obama also must carry Hampton Roads, the heavily populated and politically diverse area around Norfolk and Newport News that is dominated by African Americans, military personnel and religious conservatives.

The Obama campaign is optimistic, saying it will capitalize not only on high black turnout but also on military families disaffected with the war in Iraq. "If you're a military family, you might just want to support the one who is going to bring your families home," said Rep. Bobby Scott (D), who represents the area.

Democratic strategist Dave "Mudcat" Saunders, a Roanoke native, doubts Obama's chances in Hampton Roads, saying he will instead need to pick up votes in the rural Southside, southwest Virginia and the Shenandoah Valley, a strategy that propelled Warner in 2001. But while Obama can count on high black turnout in Southside, he fared poorly in the primary in Appalachian areas.

Added to this complex landscape are two wild cards. Democrats are hoping that Obama will benefit from the Senate race of Warner, who is heavily favored to beat former governor Jim Gilmore.

"This is a unique situation, where there is both an up-ticket effect and a down-ticket effect," Kaine said. "The Obama effort on turnout is going to have a positive effect . . . that will help Mark, and I also think Mark will perform so well and organize so strongly in some traditionally Republican parts of the state that that will help [Obama]."

Then there is the possibility of a candidate picking a Virginian as his running mate. Kaine is believed to be on Obama's short list, and Rep. Eric Cantor (R) has emerged as a possibility for McCain.

"I suspect most Virginians kind of like the notion that a Virginian can be in key leadership nationally," Kaine said. "How that translates into any effect on Election Day, I don't know."

For now, though, such prospects are secondary to the confrontation on the ground, where there appears to be much more ferment on Obama's side. Late last month, a roomful of volunteers in Arlington made calls looking for supporters to come out for a Democratic canvass that drew 2,000 people statewide.

One, Nolan Fox, moved to the area after graduating from the University of Florida in May because he wanted to help Obama and thought Virginia would be even more closely fought than his home state. "We're going to need to get massive turnout in Northern Virginia," he said.

The energy level was a bit lower a couple of days later at McCain's Crystal City office, where 50 volunteers gathered before going to knock on doors.

"You're going out canvassing for who?" said Walker, trying to rally the troops.

Among the most eager to get to work was Warren Robinson, 23, of Alexandria. He relishes Virginia's competitiveness, despite its implications for McCain's chances. "Personally, for me, it's exciting, because Virginia Republicans can make a difference," he said. "But for other Republicans, it's a concern."