Democrats rode a wave of dissatisfaction with President Donald Trump to win control of the US House of Representatives, giving them the opportunity to block the US leader’s agenda and open his administration to intense scrutiny.

But during the midterm elections, two years after he won the White House, Mr Trump and his fellow Republicans expanded their majority in the US Senate following a divisive campaign marked by fierce clashes over race and immigration.

Tuesday’s vote was seen as a presidential referendum on the Republican firebrand.

READ MORE: Midterm elections live results

Democrats won governorships on Tuesday in several US states that supported the Republican leader in 2016 but lost high-profile races in Florida and Ohio, as voters cast ballots in dozens of gubernatorial contests across the country.

Their win over the House will create a clear hurdle for Republicans to easily pass legislation through both chambers of Congress, clouding the outlook for some of Mr Trump’s key economic proposal.

The House loss means Mr Trump is likely to face investigations into his tax returns, his businesses and his administration by Democratic lawmakers.

His legislative agenda, including a proposal for a middle-class income tax cut, is likely to be stalled.

Democrats won governorships on Tuesday in several US states that supported the Republican leader in 2016 but lost high-profile races in Florida and Ohio, as voters cast ballots in dozens of gubernatorial contests across the country.

After hailing his “tremendous success,” the US leader tweeted to praise himself.

He said: “There’s only been 5 times in the last 105 years that an incumbent President has won seats in the Senate in the off year election. Mr Trump has magic about him. This guy has magic coming out of his ears. He is an astonishing vote getter & campaigner.

“The Republicans are unbelievably lucky to have him and I’m just awed at how well they’ve done. It’s all the Trump magic – Trump is the magic man. Incredible, he’s got the entire media against him, attacking him every day, and he pulls out these enormous wins.” Ben Stein, “The Capitalist Code”

“How do the Democrats respond to this? Think of how his position with Republicans improves-all the candidates who won tonight. They realize how important he is because of what he did in campaigning for them. They owe him their political career.” Thanks, I agree!”

The party that controls the White House usually loses seats in the first congressional midterm elections two years after a presidential victory.

President Barack Obama’s Democrats lost 63 seats in 2010.

There was some satisfaction among Mr Trump and his aides that the losses were not as bad as had been projected by strategists who said a Democratic “blue wave” would take away 40 House seats.

Republican strategist Scott Reed said: “Trump should be feeling good right now. They finished strong. They picked up seats in the Senate and they minimized the ‘blue wave’ in the House.

“These midterms are historically tough for a White House.”

Mr Trump and his advisers felt that adding at least two seats to the Republicans’ Senate majority helped blunt the impact of the House outcome.

The hotly contested race in Georgia, where Democrat Stacey Abrams was seeking to become the first black woman to be elected governor of a US state, remained too close to call early on Wednesday.

In Florida, Democrat Andrew Gillum lost his attempt to become the state’s first black governor, suffering a narrow defeat to Republican Ron DeSantis in a contest that drew national attention.

Mr Gillum, the 39-year-old mayor of Tallahassee, told supporters at his election night party: “I still plan to be on the front lines alongside every one of you when it comes to standing up and fighting for what we believe in.”

Small groups of people embraced, with tears streaming down their faces.

Republicans also scored a major victory in Ohio’s governor race, where Mike DeWine, the state attorney general, defeated Democrat Richard Cordray, who served as the first director of the US Consumer Financial Protection Bureau.

But in Wisconsin, Democrat Tony Evers pulled off a narrow win in unseating Republican incumbent Scott Walker.

The two-term governor, who also survived a Democratic-driven recall election in 2012 after ending collective bargaining for public workers, briefly ran for president in 2016.

In addition to Wisconsin, Democrats also won governor races in three other states – Michigan, Pennsylvania and Kansas – that supported Mr Trump in 2016, bolstering the party’s hopes of capturing those states in the 2020 presidential election.

In Michigan, Democrat Gretchen Whitmer turned back Republican Bill Schuette in the contest to replace Republican Governor Rick Snyder, who could not run again due to term limits.

In Kansas, Democrat Laura Kelly defeated Kris Kobach, a staunch Trump ally, where outgoing Republican Governor Sam Brownback suffered from low approval ratings.

Democratic candidates also triumphed in Illinois, Maine, New Mexico and Nevada, where Republicans had held the governorships. All told, Democrats had flipped at least seven Republican-held governorships without suffering any losses as of early Wednesday morning.

While much of focus of the elections on Tuesday was on which party would win control of the US Congress, Republicans and Democrats were battling across the country for state-level power, which could have a major impact on issues such as congressional redistricting and healthcare.

In Georgia, Ms Abrams, 44, was locked in a tight battle with Republican Brian Kemp, the state’s secretary of state.

There was a minor party candidate also in the race, and under Georgia law, if no candidate exceeds 50 percent of the vote, the top two finishers advance to a December runoff election.

By 2 am EST (7am GMT), Mr Kemp held a three-point lead, but Ms Abrams told her supporters that she expected a runoff once all votes were counted.

She said: “I promise you tonight that we are going to make sure every vote is counted.

“We are still on the verge of history, and the best is yet to come.”

Another Democrat trying to make history was Ben Jealous, who lost his bid to become Maryland’s first black governor to incumbent Republican Larry Hogan.

The races in Florida and Georgia were seen as a test of whether liberal candidates could prevail in Southern states, where centrist Democrats have repeatedly lost, by appealing to a coalition of young and minority voters.

Both DeSantis and Kemp had strong support from Trump, who traveled to their states in the closing days of the campaigns to energize Republicans at “Make America Great Again” rallies. Democratic former President Barack Obama swooped in to boost the Democrats, and media star Oprah Winfrey visited Georgia on behalf of Abrams.

Accusations of race-baiting dogged Kemp, 55, and DeSantis, 40, who denied the allegations. Neither Georgia nor Florida has elected a Democratic governor in 20 years.

“We all learned in 2016 not to count on anything, not polls, not election integrity, not the electoral mood,” Dawn Hucklebridge, 36, a friend of Gillum, said at his election night gathering as it became clear he would likely lose. “I’m pretty disappointed.”

Going into Tuesday, Republicans controlled 33 governors’ mansions and two-thirds of state legislative chambers.

The Democratic Party said it flipped at least six state legislative chambers on the strength of local races. Democrats now have complete control of state government in Colorado, New York, Illinois, Maine and New Mexico.

Democrats, playing catch-up after a net loss of 13 governorships and more than 900 state legislative seats during the eight-year Obama administration, fielded their largest slate of legislative candidates in more than three decades.

The outcome of elections for state positions could also affect future control of the US House of Representatives.

Governors and hundreds of legislators elected this year will be in office when congressional districts are redrawn after the 2020 Census. In some states, a governor’s power to sign or veto congressional maps could decide the partisan balance.

Republicans were eyeing a potential pickup in Connecticut, traditionally a Democratic state, where the contest was too close to call on Wednesday morning.

In Colorado, Democrat Jared Polis became the first openly gay man to be elected governor of a US state. But Democrat Christine Hallquist lost her bid to become the first openly transgender US governor in Vermont, where Republican incumbent Phil Scott won re-election.