Retiring Sen. Richard C. Shelby (R-Ala.) has said he plans to spend $5 million of his campaign funds to help his former chief of staff in the Republican primary to replace him, according to two people familiar with the conversations.

The massive infusion of cash could have a major impact in the hotly contested race, in which Rep. Mo Brooks (R-Ala.), a top proponent of former president Donald Trump’s election conspiracies, has struggled to keep up in fundraising after winning the former president’s endorsement.

Shelby, 87, whose 2022 retirement will end six terms in the Senate, has $9.7 million in cash in his campaign account and $6.5 million in his leadership PAC, according to federal records. He has told others that $5 million of it will go to an independent SuperPAC supporting Katie Britt, 39, who after leaving his staff served as the CEO of the Business Council of Alabama, according to two people who spoke on the condition of anonymity to describe private conversations.

Blair Taylor, a spokeswoman for Shelby, declined to comment on his spending plans.

“The Senator’s support for Katie is well known,” she said in a statement. “He will continue to back her as the race develops in whatever ways are most appropriate, as he believes she is the best candidate to serve the people of Alabama.”

Though Democrats see no clear path to a general election victory in Alabama this cycle, the race has become one of the most contested in the nation, as different parts of the Republican Party jockey for position.

Brooks said Wednesday that he was not surprised by the possibility that Shelby would sink money into the race. A key part of his current campaign is pitching himself as a more pro-Trump alternative to Shelby’s politics, which he described as reflecting the “establishment, never-Trump, RINO, special-interest group wing of the Republican Party.”

“I entered this race after factoring in that Richard Shelby would probably put millions in on Katie Britt’s behalf,” Brooks said. “They are hand in glove.”

Britt, who is running as a social conservative focused on business development in the state, recently received the coveted endorsement of the Alabama Farmers Federation and has raised more than twice as much money as Brooks.

“Katie’s opponent is nowhere to be found on the campaign trail just like he’s been asleep on the job for decades. He’s the Joe Biden of Alabama: 40 years running for office, six terms in Congress, and nothing to show for it but empty words,” Sean Ross, a spokesman for Britt, said in a statement. “It is clear that Alabamians are ready for fresh blood, and that’s why he is so panicked.”

But Brooks, a member of the House Freedom Caucus who warned about “massive voter fraud” during the 2020 election that did not materialize, has a major advantage with Trump’s endorsement in a state the then-president won with 62 percent of the vote that year.

Brooks spoke at a rally near the White House before the Jan. 6 Capitol riot, urging his fellow Republicans to reject the election results. “Today is the day American patriots start taking down names and kicking ass,” he announced before Trump addressed the crowd.

A third candidate in the race, Lynda Blanchard, is a business executive who served as Trump’s ambassador to Slovenia and has given herself a loan of $5 million. If no candidate wins a majority of votes in the May 24 Republican primary, the top two finishers will compete in a runoff.

Alabama is one of several Senate contests in which Trump’s endorsement has done little to clear the field in Republican primaries. He has responded by releasing statements attacking Shelby, calling it outrageous that other Republicans are “wasting money” by challenging Brooks and dismissing Britt as Shelby’s “assistant.”

Several outside groups, including the pro-Brooks Club for Growth and a local pro-Britt SuperPAC called the Alabama Conservatives Fund, have already become involved in the primary. Internal polls by campaigns and groups have given conflicting pictures of how close the race has become.

“What that means is Mo Brooks needs to raise significantly greater money himself,” said Club for Growth President David McIntosh, when told Shelby had said he plans to spend millions on the election. “We haven’t set a fixed budget, but we will spend what we need so he wins.”

Shelby, who is widely credited with building up the Huntsville area as a major center for federal contracting, made waves in 2017 when he announced weeks before a special Senate election that he would not vote for the Republican candidate, former state Supreme Court judge Roy Moore, who had been accused of improper contact with teenage girls when he was in his early 30s.

Moore lost that election to Democrat Doug Jones.