Democrats rode a wave of dissatisfaction with President Donald Trump to win control of the US House of Representatives on Tuesday, Fox News and NBC News projected, giving Democrats the opportunity to block Trump’s agenda and open his administration to intense scrutiny.

In midterm elections two years after he won the White House, Trump and his fellow Republicans were set to maintain their majority in the US Senate, CNN, NBC and ABC News said, following a divisive campaign marked by fierce clashes over race, immigration and other cultural issues.

At last count, Democrats had gained a net 14 of the 23 Republican-held seats needed to capture a majority.

With a House majority, Democrats will have the power to investigate Trump’s tax returns and possible conflicts of interest, and challenge his overtures to Saudi Arabia, Russia and North Korea.

They also could force Trump to scale back his legislative ambitions, possibly dooming his promises to fund a border wall with Mexico, pass a second major tax-cut package or carry out his hardline policies on trade.

S&P equity index futures erased most of their gains on expectations Democrats would seize the House.

A simple House majority would be enough to impeach Trump if evidence surfaces that he obstructed justice or that his 2016 campaign colluded with Russia. But Congress could not remove him from office without a conviction by a two-thirds majority in the Republican-controlled Senate.

Democrats in the House could be banking on launching an investigation using the results of U.S. Special Counsel Robert Mueller’s already 18-month-old probe of allegations of Russian interference on Trump’s behalf in the 2016 presidential election. Moscow denies meddling and Trump denies any collusion.

Tuesday’s result was a bitter outcome for Trump, a 72-year-old former reality TV star and businessman-turned-politician, after a campaign that became a referendum on his leadership.

Down the stretch, Trump hardened his rhetoric on issues that appealed to his conservative core supporters, issuing warnings about a caravan of Latin American migrants headed to the border with Mexico and condemnations of liberal American “mobs.”

Democrats turned out in droves to register disapproval of his divisive rhetoric and policies on such issues as immigration and his travel ban targeting several Muslim-majority countries.

A record number of women ran for office this election, many of them Democrats turned off by Trump’s policy agenda.

The election results mean Democrats will resume House control in January for the first time since the 2010 election, beginning a split-power arrangement with the Republican-led Senate that may force Trump to scale back his legislative ambitions and focus on issues with bipartisan support, such as an infrastructure improvement package or protections against prescription drug price increases.

It also will test Trump’s ability to compromise, something he has shown little interest in over the last two years with Republicans controlling both chambers of Congress.

The loss of power will test Trump’s political hold on House Republicans, most of whom had pledged their support for him lest they face the wrath of the party’s core supporters, who remain in his corner.

Most Democratic candidates in tight races stayed away from harsh criticism of Trump during the campaign’s final stretch, focusing instead on bread-and-butter issues like keeping down healthcare costs, maintaining insurance protections for people with pre-existing medical conditions and safeguarding the Social Security retirement and Medicare healthcare programs for senior citizens.

The final weeks before the election were marked by the mailing of pipe bombs to his top political rivals, with a political fan of Trump arrested and charged, and the mass shooting at a Pittsburgh synagogue in which 11 people died, sparking a debate about Trump’s biting rhetoric and whether it encouraged extremists.

In the House, Democrats picked up seats across the map, ousting incumbent Republican Barbara Comstock in suburban Virginia and sending Donna Shalala, a former Cabinet secretary under President Bill Clinton, to the House in south Florida.

Some of the biggest Democratic stars of the campaign season were struggling. Liberal House member Beto O’Rourke became a national sensation with his underdog US Senate campaign but fell short in conservative Texas, and Andrew Gillum was trailing Republican Ron DeSantis in his quest to become the first African-American governor of the key swing state of Florida.

Incumbent Democratic Senator Joe Manchin won a hotly contested race in conservative West Virginia, and conservative Marsha Blackburn held a Senate seat for Republicans.