A funny thing happened on the way to Judge Roy Moore's downfall in the Alabama senatorial election.

It's not happening.

And it's clear that the reason is President Donald Trump.

Just two weeks ago, Moore was accused of having improper sexual contact with an underage girl in the 1970s. The Washington Post published the story with those accusations on November 9th. It quickly wiped out his large lead in the polls.

Looking at the RealClearPolitics meter of polling trends in the race, a clear pattern emerges. Moore's popularity plummets and Democrat challenger Doug Jones' soars on November 11. That's the date of the first polls released after the story broke. The downward trend continued until November 21st.

Then, Moore's numbers suddenly started to recover. Two new polls released Wednesday show the Republican leading Jones by six and five points, respectively.

So what happened on November 21st to stem and then reverse the tide?

The most obvious answer is that President Trump came to his defense:

I can tell you one thing for sure: We don't need a liberal person in there, a Democrat, Jones. I've looked at his record, it's terrible on crime, it's terrible on the border, it's terrible on the military. We do not need somebody that's going to be bad on crime, bad on borders, bad with the military, bad for the Second Amendment.

After that the bleeding in Moore's polls stopped. Case closed.

Donald Trump's name might be mud in the blue states, the big coastal cities, and the halls of the congressional establishment, but in Alabama he still holds sway.

And more importantly, President Trump knows just how to frame the argument at the right time. Just like he persuaded a lot of reluctant conservatives to vote for him in 2016 by reminding them their only other viable option was Hillary Clinton, he's doing it again with Roy Moore.

When McConnell and the rest of the GOP established went into a full court press to get Moore to step down from the race, President Trump's response became even more important. And he responded by bucking McConnell and company and playing that purely conservative vs. liberal card.

One would have to excuse McConnell if he thought he had Moore finished off. When McConnell was a relative newcomer in the Senate in the mid-1990s, he played an integral role in forcing fellow Senator Bob Packwood's resignation on sexual assault allegations. But times have changed and there wasn't a Republican president in the White House back when Packwood was under fire.

If Moore wins, it will be the latest proof of just how toothless the GOP establishment remains in the wake of its embarrassing rout at the hands of Donald Trump in the 2016 primaries. The other main proofs are the failure to pass the Obamacare repeal and the difficulties and the missteps in the preparation of the tax reform bill so far.

It's time for McConnell and the others in the Congressional leadership to consider what this means for them and how to respond. Moore has vowed to help bring McConnell down as majority leader if he gains entry into the Senate chamber. Even if Moore is expelled as some Republican senators have promised to do, McConnell's failure to get him to withdraw or defeat him at the ballot box should lead to a no confidence vote in his leadership.

Either way, President Trump wins. No matter how much the Republican Party may want to run away from him, it clearly cannot. The GOP base, especially in super red states like Alabama, simply will not allow it.

Commentary by Jake Novak, CNBC.com senior columnist. Follow him on Twitter @jakejakeny.

For more insight from CNBC contributors, follow @CNBCopinion on Twitter.