House Speaker Paul D. Ryan’s announcement Wednesday that he will forgo reelection and relinquish his gavel in January triggers an unpredictable and unexpectedly early scramble to determine who will succeed him atop the Republican hierarchy.

Ryan’s departure would appear to clear the way for lower-ranking GOP leaders, including Majority Leader Kevin McCarthy (Calif.) and Majority Whip Steve Scalise (La.), to move up the ladder. But key uncertainties, starting with whether Republicans will be able to maintain their House majority, could keep the race unsettled for months.

“Everybody will start jockeying for position immediately,” said Rep. Mark Meadows (R-N.C.), chairman of the House Freedom Caucus and an influential member of the GOP’s conservative bloc. “They won’t wait for nine months.”

Still, it could be months before the derby truly takes shape. One big unknown is what exactly the House Republican Conference will look like come January 2019: At least 38 serving GOP members will not return next year, and dozens more incumbents are at risk of losing their seats. In the meantime, potential leaders could be judged by their peers based on the size of their fundraising totals and campaign schedules.

“I think that everybody’s going to help us win the majority, and then there’ll be a race for speaker, assuming we get the majority,” said Rep. Steve Stivers (Ohio), chairman of the National Republican Congressional Committee.

McCarthy and Scalise, in the No. 2 and No. 3 spots of the conference, respectively, hold a key advantage in any leadership showdown: relationships.

McCarthy has assiduously developed close ties with GOP members, personally recruiting dozens to run in the landmark 2010 Republican landslide, and he has cannily adjusted to a shifting political climate in recent years. More recently, he has cemented those relationships with campaign cash, raising nearly $9 million already this year — most of which gets doled out to vulnerable members.

Scalise, as the lead Republican vote counter, is the member of GOP leadership whom most rank-and-file members interact with on a routine basis, and his Capitol office suite tends to be a hub for lawmakers when the House is in session. Like McCarthy, he is a gregarious backslapper with a sharp memory and shrewd instincts.

But it is his personal saga of the past 10 months — being shot in June by a would-be assassin who targeted Republican lawmakers practicing baseball, nearly dying on an operating table and enduring a grueling recovery to return to work in the fall — that has put him in a new light and could allow him to leapfrog McCarthy under the right circumstances.

It is unusual in recent decades for a congressional leadership scramble to play out over an extended period. Not since Tip O’Neill (D-Mass.) announced his 1986 retirement two years in advance has a House speaker served an extended period as a lame duck.

Speaking to reporters Wednesday, Ryan compared the situation to former Senate minority leader Harry M. Reid’s decision in March 2015 to retire — nearly two years before the Nevada Democrat would ultimately leave office. Reid continued to wield power after the announcement, but the succession process was relatively bloodless: Sen. Charles E. Schumer (D-N.Y.) claimed Reid’s mantle within hours of the announcement, and little drama persisted.

It is not at all clear that McCarthy would be able to step into Ryan’s shoes so easily. When John A. Boehner (R-Ohio) announced suddenly in 2015 that he would relinquish the speakership, McCarthy made an effort to move from majority leader to speaker, only to withdraw in dramatic fashion after he was unable to corral votes from conservative hard-liners who were afraid he would hew too closely to the Boehner mold.

That opened up a leadership vacuum that Ryan ultimately filled, and several lawmakers said they hoped to avoid that kind of scramble this time around.

“We’ve had a job that nobody wanted. At least now we have a job that a couple people want, so that’s good,” said Rep. Rob Woodall (R-Ga.).

Numerous lawmakers said Wednesday that Ryan would have no problem maintaining power through the end of the year, though some voiced skepticism.

Rep. Thomas Massie (R-Ky.) said it would be “unprecedented” to drag the leadership race out for months.

“Some candidates won’t survive the scrutiny,” he said in an interview. He later tweeted that it would be “improbable” for Ryan to stay that long.

The major factor for McCarthy this time around — and what could be an overwhelming aid to his leadership ambitions — is his close relationship with President Trump, forged during the rancorous 2016 Republican presidential primaries. McCarthy emerged as a key ally for Trump and as someone he could call to get a frank rundown of congressional happenings.

After Trump moved into the presidency, McCarthy maintained close ties and has been a frequent visitor to the White House — including a scheduled Wednesday night dinner where he is expected to dine with the president alongside other top GOP congressional leaders. McCarthy has kept Trump apprised of policy and political happenings on Capitol Hill in frequent calls to his cellphone and, at one point, was a leading contender to be named White House chief of staff.

Trump’s fondness for McCarthy — as well as other gestures from the majority leader — have improved his standing with conservatives and, in the view of numerous lawmakers and aides, could prevent a repeat of his 2015 stumble.

Boehner sees McCarthy as the presumptive favorite. “I think Kevin McCarthy did a good job as majority leader for me, and he’s done a good job for Paul, and clearly I think he’s in the No. 1 spot,” the former speaker told the Columbus Dispatch on Wednesday.

Scalise has been struggling with an episode that nearly ended his ascent within the leadership: In 2002, while serving as a state lawmaker, he attended a meeting of a white-supremacist group in Louisiana and faced a firestorm when the episode was publicized in 2014. But GOP leaders and a key Democrat — fellow Louisiana Rep. Cedric L. Richmond, who is now chairman of the Congressional Black Caucus — rallied behind him, and the furor subsided.

Scalise is also well regarded in Trump’s sphere. The president has singled him out for praise since the shooting, calling him the “legend from Louisiana” during his State of the Union address in January. And as rumors of Ryan’s departure grew in recent months, Scalise simultaneously embraced a more active role as a public face of the Republican Party on Fox News Channel and other outlets while also stepping out onto the fundraising trail in a bigger way — a move largely seen on Capitol Hill as an attempt to keep up with McCarthy’s efforts.

McCarthy and Scalise have both sought to tamp down any sense of competition. “I’m not running against Kevin for anything,” Scalise recently told Politico. McCarthy told reporters Wednesday that “there is no leadership election” until the House wraps up legislative work later this year.

“We’ve got a lot of months still to go, and then we’ve got to keep the majority,” he said.

That means the race to lead the House Republican Conference could simmer for months, and some members are privately musing about whether other alternatives might emerge. One GOP lawmaker, speaking on the condition of anonymity to candidly describe private conversations, said some lawmakers would prefer to “clean the barn” and elect a fresh slate of congressional leaders. But historically speaking, electing a House leader from outside the existing hierarchy — such as Ryan, who was serving as Ways and Means Committee chairman when he was elected speaker — has been the exception rather than the rule.

Without naming favorites, Ryan hinted Wednesday he favored elevating a current member of the House leadership team and that an endorsement might come down the road.

“I’ll share those thoughts later,” he said. “That election’s in November, so it’s not something we have to sweat right now.”