Republicans captured control of the House of Representatives on Tuesday and expanded their voice in the Senate, riding a powerful wave of voter discontent as they dealt a setback to President Barack Obama two years after his triumphal victory.

A Republican resurgence, propelled by deep economic worries and a forceful opposition to the Democratic agenda of health care and government spending, delivered commanding defeats to Democrats from the Northeast to the South and across the Midwest. The tide swept aside dozens of Democratic lawmakers regardless of their seniority or their voting records, upending the balance of power for the second half of Obama's term.

But Sen. Harry Reid of Nevada, the Democratic leader, narrowly prevailed and his party hung onto control by winning hard-fought contests in California, Delaware, Connecticut and West Virginia. Republicans picked up at least six Democratic seats, including the one formerly held by Obama, and the party will welcome Marco Rubio of Florida and Rand Paul of Kentucky to their ranks, two candidates who were initially shunned by the establishment but beloved by the Tea Party movement.

"The American people's voice was heard at the ballot box," said Rep. John Boehner of Ohio, who is positioned to become the next speaker of the House. "We have real work to do and this is not the time for celebration."

The president, who watched the election returns with a small set of advisers at the White House, called Boehner shortly after midnight to offer his congratulations and to talk about the way forward as Washington prepares for divided government. Republicans won at least 56 seats, not including Western states where ballots were still being counted, which surpassed the 52 seats the party won in the sweep of 1994.

The most expensive midterm election campaign in the nation's history, fueled by a raft of contributions from outside interest groups and millions of donations to candidates in both parties, played out across a wide battleground that stretched from Alaska to Maine. The Republican tide swept into statehouse races, too, with Democrats poised to lose the majority of governorships, particularly those in key presidential swing states, like Ohio, where Gov. Ted Strickland was defeated.

One after another, once unassailable Democrats like Sen. Russ Feingold of Wisconsin, Reps. Chet Edwards of Texas, Earl Pomeroy of North Dakota and Rick Boucher of Virginia fell to little-known Republican challengers.

Yet Republicans did not achieve a perfect evening, losing several states they had once hoped to win, including the Senate races in Delaware and Connecticut, because candidates supported by the Tea Party movement knocked out establishment candidates to win their nominations. But they did score notable victories in some tight races, like Pat Toomey's Senate run in Pennsylvania.

Still, the outcome on Tuesday marked nothing short of a comeback for Republicans two years after suffering a crushing defeat in the White House and four years after Democrats swept control of the House and Senate. It places the party back in the driver's seat in terms of policy, posing new challenges to Obama as he faces a tough two years in his term, but also for Republicans — led by Boehner — as he suddenly finds himself in a position of responsibility, rather than simply the outsider.

In the House, Republicans found victories in most corners of the country, including five seats in Pennsylvania; five in Ohio; at least three in Florida, Illinois and Virginia; and two in Georgia. Democrats braced for the prospect of historic defeats, more than the 39 seats the Republicans needed to win control. Republicans reached their majority by taking seats east of the Mississippi even before late results flowed in from farther West.

Throughout the evening, in race after race, Republican challengers defeated Democratic incumbents, despite being at significant fundraising disadvantages. Republican-oriented independent groups invariably came to the rescue, helping level of the playing field, including in Florida's 24th Congressional District, in which Sandy Adams defeated Rep. Suzanne Kosmas; Virginia's 9th Congressional District, where Boucher, a 14-term incumbent, lost to Morgan Griffith; and Texas' 17th Congressional District, in which Edwards, who was seeking his 11th term, succumbed to Bill Flores.

Democrats argued that the Republican triumph was far from complete, pointing to their own victories, particularly in the Senate race in Delaware, where Chris Coons defeated Christine O'Donnell, whose candidacy became a symbol of a year where unorthodox political candidates swept onto the ballot in Republican primary contests. In West Virginia, Gov. Joe Manchin III, a Democrat, triumphed over an insurgent Republican rival to fill the seat held for a half-century by Sen. Robert C. Byrd Jr. And in California, Sen. Barbara Boxer overcame a vigorous challenge from Carly Fiorina, a Republican.

But Democrats conceded that their plans to increase voter turnout did not meet expectations, party strategists said, and extraordinary efforts that Obama made in the final days of the campaign appeared to have borne little fruit.

The president flew to Charlottesville, Va., on Friday evening, for instance, in hopes of rallying Democrats to support Rep. Tom Perriello, a freshman who supported every piece of the administration's agenda, but he was defeated despite the president's appeals to Democrats in a state that he carried two years ago. Obama and the vice president rallied Ohio voters to support Gov. Ted Strickland on Sunday, but he fell to defeat.

In governors' races, Republicans were, as expected, showing gains in the nation's middle. They held onto governorships in Texas, Nebraska and South Dakota, and had seized seats now occupied by Democrats in Tennessee, Michigan and Kansas. Sam Brownback, a Republican, easily took the Kansas post that Mark Parkinson, a former Republican turned Democrat, is leaving behind.

Though Democrats, who before the election held 26 governors' seats compared to 24 for the Republicans, were expected to face losses, there were also bright spots. In New York, Attorney General Andrew Cuomo easily defeated the Republican, Carl P. Paladino, even as Republicans were expected to pick up seats in the state legislature and the congressional delegation. In Massachusetts, Gov. Deval Patrick won a second term.

As election results rolled in, with Republicans picking up victories shortly after polls closed in states across the South, East and the Midwest, House Speaker Nancy Pelosi and other party leaders made urgent appeals through television interviews that there was still time for voters in other states to cast their ballots.

But the mood in Democratic quarters was glum, with few early signs of optimism in House or Senate races that were called early in the evening. Surveys that were conducted with voters across the country also provided little sense of hope for Democrats, with Republicans gaining a majority of independents, college-educated people and suburbanites — all groups that were part of the coalition of voters who supported Obama two years ago.

The election was seen as a referendum on Obama and the Democratic agenda, according to interviews with voters that were conducted for the National Election Pool, a consortium of television networks and the Associated Press, with a wide majority of the electorate saying that the country was seriously off track. Nearly nine in 10 voters said they were worried about the economy, and about four in 10 said their family's situation had worsened in the past two years.

The surveys found that voters were even more dissatisfied with Congress now than they were in 2006, when Democrats reclaimed control from the Republicans. Preliminary results also indicated an electorate far more conservative than four years ago, a sign of stronger turnout by people leaning toward Republicans.

Most voters said they believed Obama's policies would hurt the country in the long run, rather than help it, and a large share of voters said they supported the Tea Party movement, which has backed insurgent candidates all across the country.

Voters who said Obama was a factor in their decisions Tuesday were more likely to say they opposed him than supported him. About 4 in 10 voters overall said their vote was an expression of opposition to Obama, roughly the same number said he was not a factor in their vote and one-quarter said their vote was in support of the president.

The yearlong midterm election campaign, vitriolic and aggressive in spirit, played out on an unusually wide battleground stretching from Alaska to Maine and covering nearly every state in between. In the final weeks of the race, nearly 100 congressional districts became competitive, along with a large batch of Senate and governors' races, all of which were fueled by a major influx of cash from outside groups.

The political environment left almost no Democratic senator or representative, regardless of seniority or rank, free of a forceful challenge by Republicans. The Democratic strategy was primarily rooted in defense, largely because the party had made such gains in the past two election cycles that Republicans found vast opportunities.

The Republican winds began blowing back in January when Democrats lost the seat long held by Sen. Edward Kennedy of Massachusetts, with the victory of Scott Brown serving as a motivating force for the budding Tea Party movement and a burst of inspiration for Republican candidates to step forward and challenge Democrats everywhere.

On Tuesday, the president did not leave the grounds of the White House, taking a respite from days of campaigning, so he could meet with a circle of top advisers to plot a way forward for his administration and his own looming re-election campaign. The White House said Obama would hold a news conference Wednesday to address the governing challenges that await the new Congress.

"My hope is that I can cooperate with Republicans," Obama said in a radio interview Tuesday. "But obviously, the kinds of compromises that will be made depends on what Capitol Hill looks like — who's in charge."

But even as the president was poised to offer a fresh commitment to bipartisanship, he spent the final hours of the midterm campaign trying to persuade Democrats in key states to take time to vote. From the Oval Office, Obama conducted one radio interview after another, urging black voters in particular to help preserve the party's majority and his agenda.

"How well I'm able to move my agenda forward over the next couple of years is going to depend on folks back home having my back," Obama said in an interview with Chicago radio station WGCI, in which he made a special appeal for voters to keep his former Senate seat in Democratic hands.

There was little Democratic terrain that seemed immune to Republican encroachment, with many of the most competitive races being waged in states that Obama carried strongly only two years ago. From the president's home state of Illinois to neighboring Iowa, Wisconsin, Indiana and Ohio — all places that were kind to the Democratic ticket in 2008 — Republicans worked aggressively to find new opportunities.

Two years after a historic presidential election, in which Democrats, independents and even Republicans voted on a pledge to change Washington, the coalition that carried Obama to the White House was showing significant signs of fraying. Throughout the midterm elections, the Democratic Party tried to recreate the spirit and enthusiasm of the last presidential campaign but was met with a sense of frustration and anxiety from voters that their lives had not gotten better.

For all the drama surrounding the final day of the midterm campaign, more than 19 million Americans had voted before Tuesday, a trend that has grown with each election cycle over the past decade, as 32 states now offer a way for voters to practice democracy in far more convenient ways than simply waiting in line on Election Day.