WASHINGTON — The complex and fraught politics of wealth and class, undercurrents all along in the race between President Obama and Mitt Romney, are surfacing in increasingly visible ways in the presidential campaign, presenting big risks and opportunities to both sides.


The contrasting images of the week could hardly have been more evocative.


There was Mr. Obama on Thursday at a carefully scouted location, the Kozy Corners diner in Oak Harbor, Ohio, downing a burger and fries and chatting with a group of working-class voters about pinochle and trips to Disney World. The next day, as he continued a campaign swing, he reminisced about a Greyhound-and-train trip he took around the country with his grandmother when he was 11, staying at Howard Johnson and getting a thrill from leaping into the motel pool and fetching ice from the ice machine.


And there was Mitt Romney on Thursday, roaring across Lake Winnipesaukee on a powerboat large enough to hold two dozen members of his family who had gathered for a weeklong vacation at his estate in New Hampshire. On Sunday, Mr. Romney will raise money among wealthy Republicans in the Hamptons, with his final stop a $75,000-per-couple dinner at the home of David Koch, the billionaire industrialist, who with his brother Charles has been among the leading patrons of the conservative movement.


It was a vivid manifestation of calculations made by both camps.


Mr. Obama and his allies are testing the proposition that they can avoid tripping over the line into a full-tilt attack on the wealthy and still make an aggressive case that Mr. Romney’s success came at the expense of American workers and that the Republican Party is doing the bidding of its wealthy benefactors.


Mr. Romney’s bet is that with the economy failing to gain steam and Americans deeply concerned that the nation is on the wrong track, voters will not really care if he jets across a lake on a water scooter during his vacation and once had a Swiss bank account as long as he can credibly promise to spur job creation and economic growth.


Implicit and explicit efforts by the president and his inner circle to advance the argument that Mr. Romney is an out-of-touch and rapacious capitalist, in the Romney team’s view, will be seen by voters as a transparent and hypocritical attempt by a group of Democrats, millionaires themselves, to divert attention from Mr. Obama’s failure to preside over more job creation.


“I don’t think what they’re talking about is relevant to people’s lives,” said Stuart Stevens, the chief strategist for Mr. Romney’s campaign. “This race is about the economy and Barack Obama’s responsibility for the economy.”


Presidential campaigns are never just about policies or even personalities. They tend to turn as much as anything on values, and the values in this case go to central questions about the psyche of the American electorate in 2012.


In an era of populist backlashes against the 1 percent and increased concern about the economic and social ramifications of income inequality, will the long-held assumption that the United States is an aspirational society that admires rather than resents success hold true? At a time when individual billionaires and moneyed interests can play an outsize and often shadowy role in shaping politics and policy, do political leaders have less incentive to put the needs of the poor and the middle class ahead of the agendas of their benefactors?


Those questions provide a particular opportunity for Mr. Obama, who is eager to raise the stakes in the election and make it something more than a march through four more months of unemployment and job creation reports.


Without explicitly invoking Mr. Romney’s wealth as a reason to oppose him, Democrats have sought to portray him as the embodiment of a kind of capitalism that works only for the megarich.


“Mitt Romney made over $100 million by shutting down our plant and devastated our lives,” a worker from a factory closed by Bain Capital, Mr. Romney’s private equity firm, says in an advertisement by Priorities USA Action, the pro-Obama “super PAC.”


That leaves Mr. Obama free to make the more elevated pitch that his policies would give a fair shot to the middle class, while suggesting that Mr. Romney would put the nation on a path back to the policies that brought about widening inequality, stagnant wages and corporate malfeasance.


“The viability of the middle class is not a class issue,” said David Axelrod, the Obama campaign’s senior adviser. “It’s an American issue.”


Polling suggests that the Bain-based attacks on Mr. Romney are filtering through to voters in swing states. But wealth, class and politics are a combustible mix that can blow up in unpredictable ways, and Mr. Obama is not without his vulnerabilities on that score.