Campaigning in the Mountain West, Sen. Barack Obama said that the Bush administration’s policies on warrantless wiretaps and executive authority would drive libertarian votes in his direction.

Libertarian voters played a big role in swinging control of Congress to the Democrats in 2006. Could Mr. Obama hold them against Arizona Sen. John McCain? While base voters still voted along party lines in 2006, Republicans lost big among independents. According to an analysis that David Kirby and I did, libertarians may be the largest bloc of such independent-minded swing voters. Particularly in states with high concentrations of libertarians such as Arizona, Nevada, Colorado, Montana, and New Hampshire, disaffected libertarians likely cost Republicans House and Senate seats.

Recent polls suggest that 10 to 20 percent of Americans hold “fiscally conservative, socially liberal” or libertarian views. Indeed, libertarians are a bigger share of the electorate than the much-discussed “soccer moms,” and they are increasingly a swing vote.

Libertarian voters have often given 70 percent or more of their votes to Republican candidates, including George W. Bush in 2000. But after six years of war, wiretapping and welfare-state social spending, libertarians gave barely half their votes to Republican candidates in 2006. The swing was even larger in Senate races. It seems clear that a lot of the centrist, moderate, and independent voters who swung to the Democrats in 2006 were libertarian leaners.

The presidential campaign this year has been bleak for libertarian voters, with full slates of big-government liberals and big-government conservatives.

The campaign of former New York mayor Rudolph Giuliani is especially interesting. Many libertarian Republicans were attracted to a candidate who was fiscally conservative, pro-choice, and gay-friendly. That profile, along with his Sept. 11, 2001 hero image, gave Mr. Giuliani an impressive lead in the polls for much of 2007.

But then Mr. Giuliani clashed with Rep. Ron Paul over foreign policy issues in a May 15 debate, and that led to increased scrutiny of Mr. Giuliani. Libertarian opinion leaders began to criticize Mr. Giuliani for his hawkishness and his authoritarian streak. As voters paid closer attention and libertarian criticisms accelerated, he fell in the polls. His fourth-place finish in libertarian-leaning New Hampshire-after spending a great deal of time and money there-was in retrospect the end of his campaign.

David Kirby has calculated that political futures markets were interpreting Ron Paul’s successes as a setback for Mr. Giuliani, further evidence that it was a loss of libertarian support that caused Mr. Giuliani’s campaign to plummet.

Now the choices are down to three. Hillary Clinton, a self-proclaimed “government junkie,” is not likely to have much appeal for libertarians. But what about the two frontrunners? Mr. McCain will try to keep libertarian voters in the Republican column by defining Mr. Obama as a big-government, big-spending liberal friend of Ted Kennedy and Nancy Pelosi. But President Bush and the Republican Congress have severely undermined Republican credibility on fiscal conservatism.

Mr. McCain is also the leading supporter of the war in Iraq, which is unpopular with independent and libertarian voters. And he has a long record of hostility to the First Amendment, from campaign finance regulation to regulating blogs to banning flag desecration.

But his maverick, “straight talk” image will appeal to libertarians, as will his support for free trade and a reasoned approach to immigration reform. He could put some meat back on that maverick image by announcing that his attempt to crack down on political speech was misguided-and by reminding voters of disagreements with the religious right.

Mr. Obama offers virtually the opposite profile. He’s been against the war from the beginning. He has tried to scale back the excesses of the Patriot Act and promises to review Bush’s sweeping claims of executive power. His rhetoric about moving beyond liberal-conservative fights appeals to libertarians and independents.

But buried inside the soaring eloquence of his speeches is a veritable laundry list of taxpayer handouts for every voting bloc, and he has even questioned the benefits of free trade. If he wants to appeal to libertarian and independent voters, he should show a tiny bit of independence from the Kennedy-Pelosi-Clinton-labor agenda. He could advocate Social Security private accounts as a way for low-income families to build wealth, or endorse school choice for children condemned to failing schools.

Republicans have been trying to drive libertarian voters out of their party. But so far Democrats aren’t jumping on that opportunity.