WASHINGTON—Republicans clinched control of the House more than a week after Election Day, with GOP lawmakers on course for another narrow majority that will test party unity as they work to pass President-elect Donald Trump ’s second-term agenda .

The victory in the House means Republicans have full control of Washington next year, after winning the White House and the Senate, where the GOP will have a 53-47 majority.

A win by GOP Rep. Juan Ciscomani in Arizona gave Republicans the 218 seats needed for a majority of the House’s 435 lawmakers, the Associated Press projected late Wednesday. Democrats have so far won 208 seats, while some contests are still uncalled.

For days, both Democrats and Republicans have expected that the GOP would keep the majority. But the close nature of many races , and slow vote counting in California, had prompted the Associated Press to hold off on making the projection until now.

The result shows the parties effectively fought to a standstill. In New York, Democrats saw gains in battleground districts on Long Island and upstate. George Whitesides, a Democratic businessman, defeated GOP freshman Rep. Mike Garcia, a former Navy pilot, in an exurban Southern California district.

The pickups largely stopped there for Democrats as the party struggled to gain ground in other contests. California Republicans including Reps. Ken Calvert and David Valadao won close races. The GOP also flipped seats: two in Pennsylvania, one in Colorado and another in the race to succeed Rep. Elissa Slotkin (D., Mich.), who was elected to the Senate.

Republicans are already trying to head off drama in the new Congress. On Wednesday, Trump endorsed House Speaker Mike Johnson (R., La.) to remain in his post, moving to unify GOP lawmakers and avoid a replay of the fights that dragged down the party over the past two years.

Trump told House lawmakers that he is “with Johnson all the way,” according to several lawmakers at a closed-door meeting ahead of their vote picking Johnson to be the GOP nominee for speaker. With the party in charge of the White House, Senate and House, Trump urged Republicans to stay focused and recognize the importance of coming together to support his administration’s policy goals, which include major tax cuts and other policy priorities.

House Republicans voted Wednesday on their picks for leadership positions for the next Congress. In a competitive race, Rep. Lisa McClain (R., Mich.) was elected to be House Republican Conference chair, the No. 4 spot in leadership, succeeding Rep. Elise Stefanik (R., N.Y.), who was picked by Trump to serve as the U.S. ambassador to the United Nations.

The conference unanimously backed keeping Johnson as speaker, a position he has held for a year, but some lawmakers made clear they still had complaints.

In past interviews, Johnson has compared himself to a quarterback on a team in which Trump is the head coach. This weekend, Johnson is flying to Florida to meet with the president-elect at his Mar-a-Lago club to hash out the legislative plan for next year.

Former Speaker Kevin McCarthy won the GOP vote in November 2022 but faced 31 dissenters, presaging a drawn-out speaker vote the following January that went to 15 rounds over several days. McCarthy was then ousted in October 2023 after Rep. Matt Gaetz (R., Fla.), who is now Trump’s pick for attorney general, called a House floor vote to vacate the chair. Seven other Republicans joined Democrats in voting to oust him.

On Wednesday, Rep. Dusty Johnson (R., S.D.) said that he brokered a deal with members of the hard-line House Freedom Caucus to increase the number of lawmakers needed to call such a vote, increasing it to nine members from one.

“Because of this agreement, we are in a better position to move forward the Republican agenda,” he said.

Rep. Laurel Lee (R., Fla.) said she thinks Trump will unify the conference. “Supporting him and supporting his policies will be a common goal,” she said.

But Rep. Chip Roy (R., Texas), a frequent Johnson critic, said he and an unspecified number of other Republican lawmakers “are not able—yet—to unite” behind Johnson or any other candidate. He blasted a proposal that some colleagues have floated to punish Republican lawmakers who vote down procedural measures, which he said was unfair retaliation.

Rep. Anna Paulina Luna (R., Fla.) told reporters after the vote that, while no one objected to Johnson’s bid, potential detractors plan to raise their concerns about his leadership and negotiate demands before the January vote.

Rep. Scott DesJarlais (R., Tenn.) said any challenger would have no chance against Johnson.

“I just hope we don’t put on a s— show Jan. 3,” he said, referring to the date of the full House floor vote for speaker.

Write to Katy Stech Ferek at katy.stech@wsj.com and Xavier Martinez at xavier.martinez@wsj.com

Corrections & Amplifications undefined Former Rep. Kevin McCarthy (R., Calif.) won the Republican conference’s vote for speaker in November 2022. An earlier version of this article incorrectly gave the month of that vote as October 2022. (Corrected on Nov. 13)