Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

President Donald Trump on Tuesday night threw his support behind Luther Strange in the Alabama special election to replace Jeff Sessions, shaking up a race he’d widely been expected to stay out of.

Trump tweeted his "complete and total endorsement" for Strange — who was appointed to fill the seat temporarily in February after Sessions was confirmed as Attorney General — posting that he "has done a great job representing the people of the Great State of Alabama."

Trump is now front-and-center just days before the Tuesday special election, despite Alabama Republicans having been told in recent weeks that the White House would remain on the sidelines.

Alabama Republican Sen. Luther Strange waves to constituents before a Republican Senate candidate forum on Aug. 4 in Pelham, Alabama. Brynn Anderson / AP

A senior Alabama GOP official told NBC News Trump's endorsement of Strange was a surprising moment for the state's Republicans. The official, who spoke on condition of anonymity, said there was no heads up about whether the White House was going to get involved in the race — until Trump’s tweet Tuesday night.

"My jaw did drop," the official said, "because that’s big."

When asked why Trump felt compelled to endorse — and for Strange — a senior White House official told NBC that the Alabama senator has been a "steadfast supporter of the president’s agenda."

Noting Trump’s 2016 margins for victory both in Alabama overall, and on a county-level (Walker County went 83 percent for Trump in November), the Alabama official said "in some other state, I’m sure (Trump's endorsement) is valuable, but in our state it really is monumental."

This official predicted the tweeted endorsement may not sway those voters who were already decided, but with a significant percentage of voters still considering their options, Trump’s nod could be a big factor.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"If [Strange] is No. 1 one in the runoff, there’s the story, the official said, adding that if Strange doesn’t make the runoff it could erode the narrative of Trump’s influence in the state.

Strange, along with the other two candidates in the race — Rep. Mo Brooks, R-Ala., and Roy Moore, the twice-elected, twice-deposed Chief Justice of the Alabama Supreme Court — have each attempted to ally themselves with Trump, who carried every county in the state's presidential primary last year and defeated Hillary Clinton by an almost 2-1 margin in November.

Senator Luther Strange has done a great job representing the people of the Great State of Alabama. He has my complete and total endorsement! — Donald J. Trump (@realDonaldTrump) August 9, 2017

Moore, who is popular among religious conservatives, has said "God…sent Donald Trump in there," while Brooks, a Tea party favorite, has vowed to read the King James Bible on the Senate floor until the president's border wall with Mexico gets built. Strange has called Trump’s election a "Biblical miracle."

Moore is leading in most polls. If no candidate hits 50 percent on Tuesday, the top two candidates will move on to a runoff on Sept. 26, before the general election in December.

Moore is widely expected to take one of the slots, while Brooks and Strange are seen as competing for the second spot in the runoff, leading to increased acrimony between them in the final weeks of the race.

Following Trump’s surprise tweet on Tuesday, Brooks doubled down on his criticism of Strange and accused Senate Majority Leader Mitch McConnell, R-Ky., a Strange supporter, of "misleading" the president into making the endorsement.

"I respect President Trump, but I am baffled and disappointed Mitch McConnell and the Swamp somehow misled the President into endorsing Luther Strange," Brooks said.

"The President has bigger things going on than a campaign, that’s for sure," he added. "We believe our message will win out over the Swamp and Lyin’ Luther."

Hours later, Brooks' campaign Twitter account retweeted a Trump tweet that took a shot at McConnell, adding Brooks' own message: A request for the president to "reconsider" his endorsement of Strange.

"I agree completely, Mr. President. McConnell & Strange don't support your agenda. I do," Brooks wrote. "Reconsider endorsement @realDonaldTrump? #DitchMitch"

I agree completely, Mr. President. McConnell & Strange don't support your agenda. I do. Reconsider endorsement @realDonaldTrump? #DitchMitch https://t.co/yfQdo3NRwn — Mo Brooks (@mobrooksforsen) August 9, 2017

Strange, who until his appointment to the Senate served as Alabama’s attorney general, had repeatedly been dubbed by his competitors as the "establishment candidate," due to his fundraising strength and relationship with McConnell. A McConnell-affiliated super PAC has said it would spend up to $10 million on the race.

Brooks has also warned that Washington establishment "swamp critters" are trying to "strong-arm" Alabama Republicans into picking their candidate.

But the lawmaker has attracted negative himself, after running a campaign ad using audio from the June shooting that injured House Majority Whip Steve Scalise (R-La.). Brooks attended the practice.

Strange, meanwhile, has been dogged by questions about his appointment to Sessions' seat by former Gov. Robert Bentley, who was shortly thereafter driven out of office by a sex scandal.

Moore — who made headlines nationally in 2003 when he was ousted from office after he refused to remove the stone Ten Commandments he had installed on the grounds of the state judicial building and who was elected chief justice again in 2012, but suspended again last year for refusing to enforce the U.S. Supreme Court’s ruling legalizing same-sex marriage — did not directly address Trump’s tweet Tuesday night.

In a tweet from his campaign account about 40 minutes after Trump’s tweet, he posted a link to a conservative podcast with the message of "how vital it is for Conservatives to unite against the establishment machine!"