WASHINGTON—Republicans picked up Senate seats in West Virginia and Ohio and beat back a challenge in Florida, Nebraska and Texas, putting them back in control of the chamber.

Candidates, party committees and outside groups poured hundreds of millions into the battle for the Senate. Republicans are now poised to determine the fate of the next president’s agenda and whether he or she will be able to confirm executive and judicial nominees, including filling any opening on the Supreme Court.

“As a new Republican Senate majority, our focus will be to take on an agenda that reflects America’s priorities—lower prices, less spending, secure borders, and American energy dominance,” Sen. John Barrasso (R., Wyo.), who chairs the Senate Republican Conference, said.

Democrats currently hold a narrow 51-49 majority in the Senate, but were defending far more seats this year including three in states won by Donald Trump in 2020.

In Ohio, wealthy former car-dealership owner Bernie Moreno defeated three-term Sen. Sherrod Brown , the only Democrat holding statewide office there, by riding on Trump’s long coattails in the state. West Virginia’s Senate seat flipped from blue to red soon after polls closed there at 7:30 p.m., with Republican Gov. Jim Justice handily winning the seat vacated by the retirement of independent Sen. Joe Manchin, who caucused with Democrats.

“Republicans had the advantage to win control of the Senate before Election Day,” said Nathan L. Gonzales, editor of Inside Politics, an elections analyst.

Democrats also lost their best offensive opportunity in the long shot of Texas, where Sen. Ted Cruz was able to fend off Rep. Colin Allred , a former NFL football player and civil-rights attorney . In Florida, Republican Sen. Rick Scott also defeated his Democratic challenger, former Rep. Debbie Mucarsel-Powell , the Associated Press projected.

“Our incumbents look strong. Our challengers are in dog fights all over the country and are holding their own,” said Mike Berg, spokesman for the National Republican Senatorial Committee. He said Republicans are clearly favored to win the majority.

It wasn’t all bad news for Senate Democrats, who held on to an open seat in deep-blue Maryland . Former Gov. Larry Hogan there lost to Democrat Angela Alsobrooks, the Associated Press projected. But Democrats are also defending seats in five other battleground states that President Biden won by less than 3 percentage points: Arizona, Nevada, Michigan, Pennsylvania and Wisconsin.

Republicans tried to capitalize on voters’ worries about inflation , border security and transgender issues, while Democrats counted on enthusiasm for abortion rights to mobilize women, suburbanites and young people.

Many voters on Tuesday said they voted along party lines for both president and their Senate candidate, but some said they were motivated by specific issues rather than party loyalty.

Sara Gift, a registered Republican in Bucks County, Pa., said she voted for both Vice President Kamala Harris and incumbent Democratic Sen. Bob Casey, over concern about abortion access. “I feel like they’re coming for contraception next,” Gift, a 47-year-old registered nurse, said of Republicans.

Jack Williamson, 86, who described himself as a lifelong Democrat, said he voted for Republican Senate candidate Mike Rogers in the Detroit suburb of Warren, Mich., because of Democrats’ policies surrounding electric vehicles, which he described as a mandate that could “destroy” the auto industry in his state. He said he also voted for Trump.

Two to five GOP pickups seen

The Cook Political Report had projected Republicans to pick up between two and five seats, including West Virginia.

A net gain of two seats was enough to secure a Republican Senate majority, as all GOP incumbents won re-election.

In the unexpectedly close race in ruby-red Nebraska , two-term incumbent Republican Sen. Deb Fischer defeated independent Dan Osborn, a former union leader.

Montana: Tester in trouble

Montana was Republicans’ best pickup opportunity after West Virginia. The state’s Sen. Jon Tester , a Democratic farmer, trailed in the polls and early returns behind a political newcomer, Tim Sheehy , a businessman and retired Navy SEAL endorsed by Trump.

Trump won Montana by 16 percentage points in 2020, and Tester needed a substantial number of Trump supporters to vote for him if he were to defy political gravity and win a fourth term.

Senate

Montana Democratic Sen. Jon Tester has been trailing in the polls. Photo: Louise Johns for WSJ

Sheehy argued that Tester’s voting record is too liberal for Montana and that the Democrat would be a rubber stamp for Kamala Harris, should she be elected.

Tester was the only Senate Democrat who didn’t endorse Harris for president, but he joined other Democrats in campaigning on abortion rights, which he framed as a personal freedom in line with Montana’s libertarian values.

Ohio: Brown tried to hang on

In Ohio, the three-term Brown was in the fight of his political life because of the strength of support for Trump in the state. The longtime trade skeptic built a personal brand that superseded shifts in the political tides.

Brown faced a barrage of negative advertising as Republicans portrayed him as a liberal, particularly on immigration and on transgender issues. Democrats tried to tarnish the Republican candidate, Moreno, as an untrustworthy car salesman by pointing to his history as the wealthy owner of a chain of auto dealerships. Democrats also made hay of comments by Moreno in September questioning why women over 50 care about abortion rights—an offhand remark with the power to stir up a major voting bloc still incensed about the Supreme Court’s 2022 decision to end federal protections for abortion.

Pennsylvania, Wisconsin, Michigan—and Texas

In Pennsylvania, Casey was fighting to survive a challenge from Republican David McCormick , a former hedge-fund executive who is attacking the three-term senator as weak on the issues of inflation and the border.

“He has failed you. He has failed Pennsylvania,” McCormick said at a rally on Sunday.

Casey responded by citing all the money that flowed to the state when he backed Biden’s coronavirus-relief package in 2021, and stressed abortion access.

Wisconsin Sen. Tammy Baldwin is seen as the most vulnerable of the Democrats in the ‘blue wall’ states. Photo: Liam James Doyle for WSJ

Republican Eric Hovde , a wealthy banker, was also trying to unseat Democrat Sen. Tammy Baldwin in Wisconsin—one of three states that form Democrats’ “blue wall” in both the presidential and Senate contests.

Baldwin was seen as the most vulnerable of the Democrats in those states, which also include Michigan and Pennsylvania. She worked to run up her margins in traditionally red rural areas , making herself an expert on dairy and other agricultural products, but was hit by Republican advertisements.

In Michigan, Republicans swooped in to support Rogers, a former House lawmaker who was competing against Democratic Rep. Elissa Slotkin to fill an open seat.

Democrats’ best hope for a pickup had been in Texas. Cruz, who was first elected to the Senate in 2012 as a conservative firebrand, recast himself as a moderate this election cycle, emphasizing his work across the aisle. Allred had tried to argue that Cruz was an extremist and criticized him for hiding in a closet when Trump supporters rioted at the U.S. Capitol on Jan. 6, 2021. Allred also tied Cruz to the loss of abortion rights in Texas, while Cruz sought to link Allred to problems with inflation and border security under the Biden-Harris administration.

Write to Lindsay Wise at lindsay.wise@wsj.com and Siobhan Hughes at Siobhan.hughes@wsj.com