House Minority Leader Nancy Pelosi (D-Calif.) and Rep. Ben Ray Luján (D-N.M.), Democratic Congressional Campaign Committee chairman, celebrate Tuesday at the Hyatt Regency hotel in Washington. (Evelyn Hockstein for The Washington Post)

Democrats seized control of the House while Republicans held the Senate on Tuesday in a national referendum on President Trump that drew record numbers of voters to the polls and opened the door to tougher oversight of the White House over the next two years.

The dramatic conclusion of the most expensive and consequential midterms in modern times fell short of delivering the sweeping repudiation of Trump wished for by Democrats and the “resistance” movement. But Democrats’ win of the House still portended serious changes in Washington, as the party prepared to block Trump’s agenda and investigate his personal finances and potential ties to Russia.

An immediate post-election change to Trump’s Cabinet came Wednesday when Attorney General Jeff Sessions resigned at the president’s request. The move threw the future of the special counsel’s Russia investigation into uncertainty and clarified partisan battle lines after light talk of compromise following the election.

Trump had declined to answer a question about Sessions’s fate hours earlier at a combative news conference where he vowed to adopt a “warlike posture” in response to any attempt by House Democrats to investigate his administration.

Democrats have gained more than the 23 House seats needed to win a majority. But some other key races remained too close to call, including the Senate contests in Arizona and Florida and the gubernatorial matchup in Georgia. Republicans appeared to lead in all three as of Wednesday afternoon.

House Democrats are prepared to launch investigations of Trump and to closely scrutinize his policies on immigration, education and health care. But they are wary of immediately pursuing impeachment, concerned that such a move would undermine lawmakers who represent districts that Trump won in 2016.

Trump said that investigations launched by the House would jeopardize prospects for bipartisan deals on issues such as trade, infrastructure and prescription drug costs.

“They can play that game, but we can play it better, because we have a thing called the United States Senate,” Trump said, referring to GOP control of the upper chamber. “ . . . I think I’m better at that game than they are, actually, but we’ll find out.”

At her own news conference, House Minority Leader Nancy Pelosi (D-Calif.) said Democrats have a “responsibility for oversight” but said committees’ efforts would not be “scattershot.”

Detailed results maps from competitive U.S. House districts

“We’ll know what we are doing and we’ll do it right,” she said.

Jockeying for House leadership positions began in earnest Wednesday. Pelosi is widely considered to be the front-runner to retake the speaker’s gavel, despite dozens of Democratic candidates calling for new leadership during the campaign.

Trump, who demonized Pelosi on the campaign trail, threw his support behind her bid.

“I think she deserves it,” he told reporters. “She’s fought long and hard. She’s a very capable person.”

On the Republican side, House Freedom Caucus Chairman Jim Jordan (Ohio) said in an interview with Hill.TV that he would challenge Rep. Kevin McCarthy (Calif.) for the role of minority leader. The move, while expected, underscored conservatives’ desire to expand their power within the GOP conference after a bruising election.

McCarthy announced his bid later in the day.

Lawmakers will return to Capitol Hill next week, and both parties will hold leadership elections this month.

In a new talking point, Senate Majority Leader Mitch McConnell (R-Ky.) cautioned Democrats against engaging in “presidential harassment” in the form of overly aggressive oversight.

“The Democrats in the House will have to decide just how much presidential harassment is good strategy. I’m not sure it will work for them,” he told reporters Wednesday.

Trump sought to make Tuesday’s elections a referendum on his presidency. Returning to his 2016 campaign playbook, he delivered fiery speeches that drew massive and enthusiastic crowds but were full of falsehoods, invective and demagoguery.

Key suburban districts rejected his pitch, along with most women.

Democrats won women’s support by 19 points, the largest margin in the history of midterm exit polling, compared with their margin of four points in 2014, according to network exit surveys from CNN. Independent women voted for Democratic candidates by a 17-point margin after narrowly supporting Republicans in 2014. And white women, a reliable voting bloc for the GOP, split their votes evenly between the two parties this year, after favoring Republicans by 14 points in 2014 and by 19 points in 2010.

Voters under 30 also favored Democrats this year by a 35-point margin over Republicans, compared with an 11-point margin in 2014, the polls found.

Democrats, who picked up at least seven governorships, performed well in several states Trump won. In Wisconsin, Democrat Tony Evers bested Gov. Scott Walker, the onetime Republican star who ran for president in 2016. Even Kansas elected a Democratic governor, rejecting Trump ally Kris Kobach.

But while the party held onto its Senate seats in West Virginia and Montana — and picked up one more in Nevada — it was disappointed elsewhere.

Sens. Joe Donnelly of Indiana, Heidi Heitkamp of North Dakota and Claire McCaskill of Missouri all lost their seats to Republicans who campaigned as Trump allies. Sen. Bill Nelson (D-Fla.), with his reelection in doubt, said Wednesday that his race was proceeding to a recount.

In some ways, the outcome was similar to that of 2016, with late polls overestimating Democratic enthusiasm and Republicans showing unanticipated resilience.

The liberal movement’s biggest stars this election cycle struggled against the odds. Florida Democratic gubernatorial candidate Andrew Gillum lost to Republican Ron DeSantis, a Trump ally. In Texas, Rep. Beto O’Rourke (D) failed to unseat Sen. Ted Cruz (R). And in Kentucky, former Marine fighter pilot Amy McGrath, a Democrat, was defeated by incumbent Rep. Garland “Andy” Barr (R).

Some Democrats held out hope for Georgia, where gubernatorial nominee Stacey Abrams refused to concede her too-close-to-call race against Republican Secretary of State Brian Kemp. The race might be headed for a recount.

Abrams and Gillum, both African American, confronted some of the most overt racial attacks since the civil rights era as they sought to make history as their states’ first black governors.

Robo-calls in Georgia featured a voice impersonating Oprah Winfrey and calling Abrams “a poor man’s Aunt Jemima.” In Florida, robo-calls mimicked Gillum as jungle sounds and chimpanzee noises were heard in the background.

Trump contributed to the simmering racial tension. Describing himself as a “nationalist,” he vilified a migrant caravan headed slowly toward the U.S. border with Mexico and released a television ad on immigration that was rejected as offensive by the major networks.

Trump also called Gillum, the mayor of Tallahassee, “not equipped,” and Abrams, a leader in the Georgia state legislature, “not qualified” to be governors.

The racial overtones put that explosive form of politics on the ballot, with major stakes for Republicans. The GOP is now overwhelmingly white, while Democrats have a much more multiracial coalition that represents the direction in which the country’s demographics are heading.

Tuesday’s results were set to transform the House in terms of gender, age and ethnicity. The new Democratic majority will be more female and more racially diverse, with several history-making members, including two Muslim women and two Native American women.

The House Republican Conference will be more white and more male as several GOP women depart.

Philip Bump, Scott Clement, Karoun Demirjian, David A. Fahrenthold, Amy Gardner, Anne Gearan, Emily Guskin, Paul Kane, Beth Reinhard and John Wagner contributed to this report.