WASHINGTON (AP) -- Democrats were on track to gain House control Tuesday night, but Republicans held their Senate majority as voters rendered a mixed verdict in the first nationwide election of Donald Trump's turbulent presidency.
The Democrats picked up the 23 seats they would need to take from the GOP, but were still short of the 218 total to wrest control with more races still undecided.
The results allowed both parties to claim partial victory, and highlighted an extraordinary realignment of U.S. voters by race, sex and education. Republicans maintained their strength in conservative, rural states, while Democrats made inroads across America's suburbs.
Women were assured of 85 seats in the House, a record.
With control of Congress, statehouses and the president's agenda at stake, some of the nation's top elections were too close to call.
Yet Democrats' dreams of the Senate majority as part of a "blue wave" were shattered after losses in many of the top Senate battlegrounds: Indiana, Missouri, Tennessee, North Dakota and Texas. They also suffered a stinging loss in Florida, where Trump-backed Republican Ron DeSantis ended Democrat Andrew Gillum's bid to become the state's first African-American governor.
"I want to encourage you to stick to the fight," said Gillum, who was thought to be a rising star with national ambitions.
In the broader fight for control in the Trump era, the political and practical stakes on Tuesday were sky high.
Democrats could derail Trump's legislative agenda for the next two years should they win control of the House. And they would claim subpoena power to investigate Trump's personal and professional shortcomings.
Some Democrats have already vowed to force the release of his tax returns. Others have pledged to pursue impeachment, although removal from office is unlikely so long as the GOP controls the Senate.
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.
The results were more mixed deeper into Trump country.
In Kansas, Democrat Sharice Davids beat a GOP incumbent to become the first Native American and gay 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 more competitive House battlefield appeared to be slipping.
"Tremendous success tonight. Thank you to all!" Trump tweeted.
History was working against the president in the Senate: 2002 was the only midterm election in the past three decades when the party holding the White House gained Senate seats.
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.
Trump encouraged voters to view the first nationwide election of his presidency as a referendum on his leadership, pointing proudly to the surging economy at recent rallies.
He 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's current job approval, set at 40 percent by Gallup, was 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.
Democrats, whose very relevance in the Trump era depended on winning at least one chamber of Congress, were laser-focused on health care as they predicted victories that would break up the GOP's monopoly in Washington and state governments.
Yet Trump's party will maintain Senate control for the next two years, at least.
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.
In Indiana, Trump-backed businessman Mike Braun defeated Democratic incumbent Joe Donnelly. In Missouri, Josh Hawley knocked off Democratic Sen. Claire McCaskill. And in Tennessee, Congresswoman Marsha Blackburn defeated former Gov. Phil Bredesen, a top Democratic recruit.
In the leadup to the election, Republicans privately expressed confidence in their narrow Senate majority but feared the House could slip away. The GOP's grip on high-profile governorships in Georgia and Wisconsin were at risk as well.
Democratic Sens. Joe Manchin in West Virginia and Tammy Baldwin in Wisconsin won re-election. And in New Jersey, Democrats re-elected embattled Sen. Bob Menendez, who, less than a year ago, stood trial for federal corruption charges. The Justice Department dropped the charges after his trial ended in an hung jury.
Meanwhile, several 2020 presidential prospects easily won re-election, including Sens. Bernie Sanders of Vermont, Elizabeth Warren of Massachusetts, Sherrod Brown of Ohio, Sen. Kirsten Gillibrand of New York and New York Gov. Andrew Cuomo.
Tuesday's elections also tested the strength of a Trump-era political realignment defined by evolving divisions among voters by race, gender, and especially education.
Trump's Republican coalition is increasingly older, whiter, more male and less likely to have a college degree. Democrats are relying more upon women, people of color, young people and college graduates.
Women voted considerably more in favor of their congressional Democratic candidate -- with fewer than 4 in 10 voting for the Republican, according to VoteCast, a nationwide survey of more than 113,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, voters skewed significantly toward Democrats by a nearly 10-point margin.
The demographic divides were coloring the political landscape in different ways.
Democrats performed well in the race for the House, a sprawling battlefield set largely in America's suburbs where more educated and affluent voters in both parties have soured on Trump.
Democrats' chances were always considered weak in the Senate, where they were almost exclusively on defense in rural states where Trump remains popular.
The races ushered in a series of firsts. Women had won 76 seats and were assured of nine more, a record.
The House was getting its first two Muslim women, Massachusetts elected its first black congresswoman, and Tennessee got its first female senator.
Georgia gubernatorial candidate Stacey Abrams, a Democrat, was in a fierce battle to become America's first black woman governor, though Democrats in Florida and Maryland lost their bids to become their states' first black governors.
"Tomorrow will be a new day in America," said House Minority Leader Nancy Pelosi, who's in line to become the next House speaker should Democrats take the majority.
Associated Press writers Eric Tucker, Jill Colvin and Zeke Miller in Washington, Kantele Franko in Westerville, Ohio and Michael Kunzelman in Silver Spring, Maryland, contributed to this report.