WASHINGTON (AP) — Democrats seized the House majority from President Donald Trump's Republican Party on Tuesday in a suburban revolt that threatened what's left of the president's governing agenda. But the GOP gained ground in the Senate and preserved key governorships, beating back a "blue wave" that never fully materialized.

The mixed verdict in the first nationwide election of Trump's young presidency underscored the limits of his hardline immigration rhetoric in America's evolving political landscape, where college-educated voters in the nation's suburbs rejected his warnings of a migrant "invasion."

Blue-collar voters and rural America embraced his aggressive talk and stances. The new Democratic House majority will end the Republican Party's dominance in Washington for the final two years of Trump's first term with major questions looming about health care, immigration and government spending.

But the Democrats' edge in the House is narrow. With 218 seats needed for a majority, Democrats have won 219 and the Republicans 193, with winners undetermined in 23 races.

The president's party will maintain control of the executive and judicial branches of the government, in addition to the Senate, but Democrats suddenly have a foothold that gives them subpoena power to probe deep into Trump's personal and professional missteps — and his long-withheld tax returns.

"Tomorrow will be a new day in America," declared House Minority Leader Nancy Pelosi, who would be in line to become the next House speaker.

It could have been a much bigger night for Democrats, who suffered stinging losses in Ohio and in Florida, where Trump-backed Republican Ron DeSantis ended Democrat Andrew Gillum's bid to become the state's first African-American governor.

The 2018 elections also exposed an extraordinary political realignment in an electorate defined by race, gender, and education that could shape U.S. politics for years to come.

The GOP's successes were fueled by a coalition that's decidedly older, whiter, more male and less likely to have college degrees. Democrats relied more upon women, people of color, young people and college graduates.

Record diversity on the ballot may have helped drive turnout.

Women won at least 85 seats in the House, a record. The House was also getting its first two Muslim women, Massachusetts elected its first black congresswoman, and Tennessee got its first female senator.

Three candidates had hoped to become their states' first African-American governors, although just one — Georgia Democrat Stacey Abrams — was still in the running.

Overall, women voted considerably more in favor of congressional Democratic candidates — with fewer than 4 in 10 voting for Republicans, according to VoteCast, a nationwide survey of more than 115,000 voters and about 20,000 nonvoters — conducted for The Associated Press by NORC at the University of Chicago.

In suburban areas where key House races were decided, female voters skewed significantly toward Democrats by a nearly 10-point margin.

Democrats celebrated a handful of victories in their "blue wall" Midwestern states, electing or re-electing governors in Michigan, Pennsylvania, Minnesota and in Wisconsin, where Scott Walker was defeated by state education chief Tony Evers.

The road to a House majority ran through two dozen suburban districts Hillary Clinton won in 2016. Democrats flipped seats in suburban districts outside of Washington, Philadelphia, Miami, Chicago and Denver. Democrats also reclaimed a handful of blue-collar districts carried by both former President Barack Obama and Trump.

The results were more mixed deeper into Trump country.

In Kansas, Democrat Sharice Davids beat a GOP incumbent to become the first gay Native American woman elected to the House. But in Kentucky, one of the top Democratic recruits, retired Marine fighter pilot Amy McGrath, lost her bid to oust to three-term Rep. Andy Barr.

Trump sought to take credit for retaining the GOP's Senate majority, even as the party's foothold in the House was slipping.

"Tremendous success tonight. Thank you to all!" Trump tweeted.

The White House announced that Trump would hold a post-election news conference at 11:30 a.m.

History was working against the president in both the House and the Senate: The president's party has traditionally suffered deep losses in his first midterm election, and 2002 was the only midterm election in the past three decades when the party holding the White House gained Senate seats.

Democrats' dreams of the Senate majority, always unlikely, were shattered after losses in top Senate battlegrounds: Indiana, Missouri, Tennessee, North Dakota and Texas.

Some hurt worse than others.

In Texas, Sen Ted Cruz staved off a tough challenge from Democrat Beto O'Rourke, whose record-smashing fundraising and celebrity have set off buzz he could be a credible 2020 White House contender.

Trump encouraged voters to view the 2018 midterms as a referendum on his leadership, pointing proudly to the surging economy at his recent rallies.

Nearly 40 percent of voters cast their ballots to express opposition to the president, according to AP VoteCast, the national survey of the electorate, while one-in-four said they voted to express support for Trump.

Overall, 6 in 10 voters said the country was headed in the wrong direction, but roughly that same number described the national economy as excellent or good. Twenty-five percent described health care and immigration as the most important issues in the election.

Nearly two-thirds said Trump was a reason for their vote.

The president bet big on a xenophobic closing message, warning of an immigrant "invasion" that promised to spread violent crime and drugs across the nation. Several television networks, including the president's favorite Fox News Channel, yanked a Trump campaign advertisement off the air on the eve of the election, determining that its portrayal of a murderous immigrant went too far.

One of Trump's most vocal defenders on immigration, Kansas Secretary of State Kris Kobach, lost his bid for governor.

Kobach had built a national profile as an advocate of tough immigration policies and strict voter photo ID laws. He served as vice chairman of Trump's now-defunct commission on voter fraud.

The president found partial success despite his current job approval, set at 40 percent by Gallup, the lowest at this point of any first-term president in the modern era. Both Barack Obama's and Bill Clinton's numbers were 5 points higher, and both suffered major midterm losses of 63 and 54 House seats respectively.

Meanwhile, the close of the 2018 midterm season marked the unofficial opening of the next presidential contest.

Several ambitious Democrats easily won re-election, including presidential prospects Bernie Sanders of Vermont, Elizabeth Warren of Massachusetts and Kirsten Gillibrand of New York. A handful of others played outsized roles in their parties' midterm campaigns, though not as candidates, and were reluctant to telegraph their 2020 intentions before the 2018 fight was decided. They included New Jersey Sen. Cory Booker, California Sen. Kamala Harris, former New York City Mayor Michael Bloomberg and former Vice President Joe Biden.

Said Warren: "This resistance began with women and it is being led by women tonight."