Updated

Democrats reclaimed control of the House of Representatives Tuesday night after eight long years out of power, dealing a major setback to President Trump's legislative agenda -- but Republicans were able to expand their narrow Senate majority and, with it, preserve the ability to confirm crucial judicial nominees.

The split decision on Capitol Hill follows one of the most intense and chaotic midterm campaign seasons in recent memory, in which President Trump barnstormed the country for GOP candidates and powerful Democrats, including predecessor Barack Obama, did the same for the other side.

For his part, Trump was able to help prevent a total Democratic takeover in Congress, and he avoided a repeat of President Obama's first midterm elections in 2010, when his party lost 6 seats in the Senate and 63 in the House.

Retiring House Speaker Paul Ryan, R-Wisc., said in a statement that "history had repeated itself" Tuesday night, noting that since 1862, the president's party has lost an average of 32 House seats during the midterms. After Tuesday's elections, Democrats appeared poised to gain approximately two dozen seats in the House, while Republicans looked to net at least two Senate seats.

"I'm proud of the campaign that our members and candidates ran in a challenging political environment," he said.

The president reacted positively but tersely to the results late Tuesday, writing on Twitter, "Tremendous success tonight. Thank you to all!" Hours later, he quoted author Ben Stein, said that "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" and that Trump "has magic about him."

In a boost for Trump, the GOP's continued hold on the Senate gives Republicans control over all critical federal judicial appointments, including nominations to the Supreme Court. Republicans flipped a number of marquee Senate seats on Tuesday, with wins by Josh Hawley over Sen. Claire McCaskill in Missouri, Rep. Kevin Cramer over Sen. Heidi Heitkamp in North Dakota, Republican Gov. Rick Scott over longtime Sen. Bill Nelson in Florida, and Mike Braun over Joe Donnelly in Indiana.

All four of those ousted Democrats opposed the confirmation of Supreme Court Associate Justice Brett Kavanuagh, who was besieged by uncorroborated -- and in some cases discredited -- allegations of sexual misconduct.

And GOP Sen. Ted Cruz also held off a well-funded insurgent challenge from Beto O'Rourke in Texas by a slim margin. (In a sign that Texas remains deeply conservative overall, popular GOP Gov. Greg Abbott defeated Democrat Lupe Valdez by more than 14 points.)

"With gains in the Senate, Republicans defied history, an achievement reached only four times in history,” Republican National Committee Chairwoman Ronna McDaniel said, adding that the GOP had turned Democrats' "tsnumani into a ripple."

But Democrats' win in the House gives fresh hope to liberals who want to investigate and perhaps even impeach the president. The takeover in that chamber ensures a contentious next two years leading into the 2020 presidential elections.

"With gains in the Senate, Republicans defied history, an achievement reached only four times in history."

— RNC Chairwoman Ronna McDaniel

Democrats will also be able to halt many items on Trump's legislative wishlist, including funding for his proposed border wall and a new middle-class tax cut -- or at least extract major concessions on issues like immigration reform before Trump gets his way.

Although the exact size of the parties' respective majorities in the House and Senate is not clear, Democrats will soon have to decide whether to restore Nancy Pelosi to her old job as speaker of the House, which she held from 2007 to 2011.

"We will have a Congress that is open transparent and accountable to the American people," Pelosi said Tuesday night. "We will work for the boldest common denominator."

“Tomorrow will be a new day in America,” she added. “We have all had enough of division. The American people want peace. They want results.”

The midterms, Pelosi said, were primarily about “restoring the Constitution’s checks and balances to the Trump administration."

Previewing an adversarial relationship with the White House even as she said Democrats "strive for unity," Pelosi charged that Republicans are becoming "more destructive every day" and are bent on enriching the wealthy.

Pelosi and top Democrats have vowed to open a series of investigations into the White House upon reclaiming the House, including probes into Trump's unreleased personal tax returns, alleged collusion with Russia, and potential ethics violations by administration officials.

"We will work for the boldest common denominator."

— House Minority Leader Nancy Pelosi, D-Calif.

Prominent firebrands including Democratic Reps. Maxine Waters, Adam Schiff, and Jerry Nadler are slated to be elevated to lead the House Financial Services Committee, Intelligence Committee, and Judiciary Committee, respectively. With control of those and other key committees, Democrats will have the legal authority to issue subpoenas to compel Republicans and others to provide documents or appear at hearings -- and to seek contempt proceedings if they don't comply.

"We will be able to get answers the Republicans were unwilling to pursue," Schiff told CNN in October. "Records that the Republicans wouldn't ask for." (Pelosi has said that trying to obtain Trump's tax returns would be "one of the first things we'd do.")

Schiff added that he would place a "very high priority" on determining whether the Trump Organization had laundered money through Russia.

Republicans, meanwhile, defied expectations of a blue wave largely on the strength of several major wins in the Senate. Cruz sealed the result with his defeat of O’Rourke in the most expensive Senate race in American history.

The 46-year-old O'Rourke, who had sought to become the first Democrat to win a statewide race in Texas since 1994, set fundraising records by taking in $70 million last quarter alone. He launched his campaign on a promise of bipartisanship and unity that contrasted sharply with Cruz's strongly conservative record.

But O'Rourke's policy proposals -- including impeaching President Trump, adopting an expensive "Medicare-for-all" program, and potentially abolishing the Immigration and Customs Enforcement (ICE), agency -- alienated many voters in Texas' conservative strongholds.

And Missouri Attorney General Josh Hawley took down vulnerable incumbent Democratic Sen. McCaskill, whose appeal in a state Trump carried by double digits in 2016 faded as she voted against Supreme Court Justice Brett Kavanaugh. On Monday, McCaskill, who has presented herself as a moderate, claimed she "didn't care" which party won the Senate.

"Obviously we fell short, and that is disappointing," McCaskill said Tuesday night. "I feel pain for people who said they're going to do more than sit on the couch and cuss the TV."

BETO BLOCKER: CRUZ TRUMPS O'ROURKE, WHO BROUGH IN RECORD-HIGH CAMPAIGN DONATIONS

The Fox News Decision Desk also assesses that Cramer will unseat one-term Democratic Sen. Heitkamp in North Dakota, scoring a crucial Senate pickup for the GOP. Heitkamp, who had long struggled against Cramer in the reliably red state, may have sealed her political fate last month when she also opposed Kavanaugh's confirmation.

In Indiana, Mike Braun, a businessman, will defeat first-term Democratic Sen. Joe Donnelly, another Democrat whose vote against Kavanaugh proved costly. The race was one of the most closely fought races in the country, and Braun's victory marks another big win for the GOP. Trump had aggressively campaigned for Braun in recent days.

FULL MIDTERM RESULTS

In another key race for Republicans, the Fox News Decision Desk projects that Republican Rep. Marsha Blackburn will defeat former Democratic Gov. Phil Bredesen to replace retiring GOP Sen. Bob Corker. While Blackburn spent all summer trailing Bredesen in the polls, she closed the gap and took the lead about a month ago, despite a last-minute endorsement by pop star Taylor Swift for Bredesen.

TAYLOR FADE: SWIFT'S ENDORSEMENT SOUNDS SOUR NOTE AFTER BREDESEN GOES DOWN

Former Republican presidential nominee Mitt Romney will also defeat Democrat Jenny Wilson to succeed retiring GOP Sen. Orrin Hatch, as expected. The former Massachusetts governor, previously a fierce Trump critic, secured his support after backing his presidency.

Democrats also saw some expected, but significant, Senate wins. New Jersey Democratic Sen. Bob Menendez will win re-election by defeating Republican businessman Bob Hugin. And the Fox News Decision Desk also projects that West Virginia Democratic Sen. Joe Manchin will win re-election by defeating Republican Attorney General Patrick Morrisey. Manchin was the only member of his party to vote to confirm Kavanaugh. In Michigan, Democratic Sen. Debbie Stabenow will win a fourth term by defeating Republican businessman John James, a combat veteran who was strongly backed by President Trump, Fox News projects.

The Fox News Decision Desk also projects that none of the four candidates in Mississippi's special Senate election will win tonight because none garnered 50 percent of the vote. The top two finishers – Republican incumbent Cindy Hyde-Smith and Democratic challenger Mike Espy -- will face each other in a runoff election on Nov. 27.

A number of other key races remain too close to call, including the contest between Montana incumbent Sen. Jon Tester and Republican challenger Matt Rosendale, the state auditor. President Trump has made it his mission to defeat Tester, who helped torpedo Trump’s nomination of White House physician Ronny Jackson to lead the Department of Veterans Affairs. At this moment, Tester has fallen behind in the race.

In Nevada, Democratic Rep. Jacky Rosen will defeat incumbent Republican Sen. Dean Heller, cutting into the GOP's gains in the Senate. Heller was widely regarded as one of the most vulnerable Republicans in Congress.

The Fox News Decision Desk also cannot yet project a winner in Arizona, where Republican Rep. Martha McSally is in a tight battle with Democratic Rep. Kyrsten Sinema to succeed retiring GOP Sen. Jeff Flake. Determining the winner could take days.

Democrats were able to regain the majority in the House by flipping key seats; they needed to take 23 for a majority. In Northern Virginia's 10th Congressional District, GOP Rep. Barbara Comstock is projected to lose to her Democratic challenger, state Sen. Jennifer Wexton. Comstock was widely seen as one of the most vulnerable Republicans in Congress.

And 77-year-old Democrat Donna Shalala, who served as Secretary of Health and Human Services under President Bill Clinton, has defeated Republican opponent Maria Elvira Salazar in Florida's 27th Congressional District, which has long been held by the GOP.

Democrat Joe Cunningham pulled off an upset by defeating Katie Arrington in in South Carolina's 1st Congressional District, which Republicans have held since 1981.

Some major Democratic efforts to flip Republican-controlled seats came up short. In Kentucky's 6th Congressional District, Republican incumbent Rep. Andy Barr has defeated Democrat Amy McGrath. The two had been competing in a neck-and-neck race, which Democrats saw as an opportunity to flip a seat in a GOP-leaning district. McGrath, the first female Marine to fly an F/A-18 on a combat mission, campaigned on a largely anti-Trump platform.

And Republican Denver Riggleman has defeated Democrat Leslie Cockburn to keep a closely watched Virginia congressional seat in the hands of the GOP. Virginia's 5th Congressional District is home to incumbent GOP Rep. Tom Garrett, who announced that he would not seek re-election earlier this year amid mounting scandals. While the district supported President Trump in 2016 by double-digits, the contest had been tight between Cockburn, a former journalist who favors Medicare-for-all, and Riggleman, a staunch Republican.

Democratic Sen. Joe Donnelly speaks during a U.S. Senate Debate against Republican former state Rep. Mike Braun and Libertarian Lucy Brenton, Tuesday, Oct. 30, 2018, in Indianapolis. (AP Photo/Darron Cummings, Pool)

Meanwhile, the Fox News Decision Desk projects that Democratic Sens. Sen. Tim Kaine in Virginia, Elizabeth Warren in Massachusetts, and Sherrod Brown in Ohio, as well as Vermont independent Sen. Bernie Sanders, will all cruise to victory.

WATCH: COMSTOCK SAYS THREAT TO IMPEACH KAVANAUGH IS 'RIDICULOUS'

Democrat and former CIA officer Abigail Spanberger also defeated Tea Party-affiliated Republican Rep. Dave Brat, who has represented the state's 7th Congressional District since 2014, when he stunned the nation by unseating then-House Majority Leader Rep. Eric Cantor.

Trump carried this district by 7 points in 2016, and it has had a Republican representative for almost 50 years. But changing demographics put it in play and led to Spanberger's win.

Fox News' Bill Sammon and The Associated Press contributed to this report.