Washington (AFP) - Republicans cruised to victory in US midterm elections, gaining control of both houses of Congress in a stinging setback for President Barack Obama and his fellow Democrats and ensuring fractious co-existence in the last two years of his presidency.

The Republicans padded their control of the House of Representatives by at least 12 seats, and in the big prize of Tuesday's midterm election they retook the Senate.

The Democratic implosion put the Republicans in position to shape if not dictate the congressional agenda, and their priorities are likely to focus on the economy.

Many pro-growth laws are ready for approval, such as authorization for the Keystone XL oil pipeline running from Canada to the Gulf of Mexico, boosting production of natural gas, helping small businesses and cutting back on government regulations.

The Republicans rode a wave of voter frustration with Washington incumbents and unpopular policies of the Obama administration to claim total congressional control for the first time since 2006.

The new legislature will take power in January.

The new Republican margin of control in the House with a cushion of at least 12 seats takes them close to achieving or surpassing their largest majority of the post-World War II era. They will go from having 45 to at least 52 seats in the 100-member Senate.

"This experiment in big government has lasted long enough. It's time to go in a new direction," Mitch McConnell, the top Senate Republican who defeated the toughest challenge to his Kentucky seat in 30 years, boomed to supporters in his victory speech.

But he sounded a conciliatory note as well, adding that while he and the president rarely see eye to eye, "we do have an obligation to work together on issues where we can agree."

Republicans have held the 435-seat House of Representatives since 2010, and they kept it safely in hand Tuesday.

Compounding Democratic woes, projections showed the GOP could gain as many as 18 House seats, giving Republicans their largest majority since 1946.

Story continues

Republicans also cleaned up in key governors' races, earning re-election in Florida, Wisconsin and Kansas and stunning Democrats by winning governorships in Democratic strongholds Maryland and Massachusetts.

But of the 36 governors' races, probably the most painful for Obama was Illinois, where Republican Bruce Rauner ousted Democrat Pat Quinn in the president's home state.

- 'Powerful repudiation' -

Democrats had worked feverishly to draw voters to the polls in a last-gasp effort, but it was not enough to halt the Republican juggernaut.

With no legislative base in Congress, Obama will struggle to pass any reforms in the final stretch of his mandate, and his opponents will be able to thwart his appointments to judicial and official posts.

The party of an incumbent president historically fares badly in elections in his second term, and every president since Ronald Reagan has left office with the opposition controlling Congress.

The Republicans, capitalizing on the nation's sour mood despite an economic recovery, essentially based their campaigns on attacks against Obama and policies like his troubled health care reform.

"It was a powerful repudiation of the Obama agenda," conservative Senator Ted Cruz told CNN.

But he repeated what many in his party have urged, that the onus now falls on Republicans to govern, particularly in the run-up to the 2016 presidential election.

"It's time for government to start getting results and implementing solutions to the challenges facing our country, starting with our still-struggling economy," House speaker John Boehner said.

While Republicans are likely to cooperate on issues like tax reform, the party will seek to breathe life into their stalled jobs bills, to gain approval of the delayed Keystone XL pipeline, roll back some carbon emission regulations and tweak Obamacare.

- Ugly from the outset-

Election night was ugly from the get-go for Obama's party.

Democrats including Senator Mark Pryor of Arkansas, Kay Hagan of North Carolina and Mark Udall of Colorado fell like dominoes as Republicans capitalized on a particularly strong set of candidates, including Arkansas' Tom Cotton and Colorado's Cory Gardner, who successfully convinced voters they would be better off with leaders not loyal to an unpopular president.

Conservative Joni Ernst won her battle in Iowa, becoming the state's first female senator.

Democratic Senator Jeanne Shaheen of New Hampshire held her seat, but that was the only good news for Democrats, as Republicans fended off challenges in GOP strongholds Georgia, Kansas and Kentucky.

The onslaught could well deepen for Democrats, with an unexpected cliffhanger remaining in Virginia, Alaska up in the air and Louisiana Democratic Senator Mary Landrieu forced into an unfavorable December 6 runoff.

The Republican performance appeared to surpass most expectations.

"They've done this about as well as they could conceivably have done it," University of Michigan assistant professor Michael Heaney told AFP.

A chastened Obama has invited the four congressional leaders to the White House on Friday.