Sen. Jeff Sessions of Alabama, the Senate's leading immigration opponent, endorsed Donald Trump today onstage during a rally in Alabama.

Sessions is the first senator to endorse Trump. Along with the endorsements of Govs. Chris Christie of New Jersey and Paul LePage of Maine on Friday, and of former Arizona Gov. Jan Brewer on Saturday, it's another sign that many in the Republican Party are beginning to accept that Trump will likely be their nominee.

But Sessions's endorsement of Trump also makes a great deal of sense. Trump is, in many ways, building on Sessions's intellectual framework.

Jeff Sessions is the forefather of Trump's immigration positions

Sessions has been perhaps the highest-profile figure in the Republican Party to call for restrictions on both legal and unauthorized immigration. He led opposition to the 2013 "Gang of Eight" comprehensive immigration reform bill in the Senate. (Ted Cruz has tried to align himself with Sessions during the campaign by saying he "fought alongside Jeff Sessions" to defeat the Gang of Eight bill; in reality, Sessions was definitely the sole leader.)

As the chair of the Immigration Subcommittee in 2015, he's focused his efforts on attacking work visa programs for letting in legal immigrants to compete for American jobs — a close cousin to Trump's own populist rhetoric on the subject.

Sessions has actually been an adviser to Trump on immigration for most of his campaign. Trump's immigration platform — which called to deport all unauthorized immigrants from the US along with their US-born children, and took a hard line against future legal immigration as well — owes quite a bit to Sessions.

At the very least, Sessions and his staff conferred with Trump in the days before the platform was released. And since Trump appeared not to know what was in his own platform during a debate last fall, rumors have circulated that Sessions's staff actually wrote the thing.

Sessions, like Trump, has gotten in trouble for not disowning the Ku Klux Klan

The timing of the Sessions endorsement makes sense: Alabama is part of Tuesday's "SEC primary" across several Southern states (as well as some Northeastern and Midwestern ones). Trump is way ahead in the polls in Alabama anyway, but an endorsement from one of the state's senior politicians can't hurt.

But the timing also presents an interesting juxtaposition — and maybe a revealing one. Because only a few hours before Sessions endorsed Trump, Trump flabbergasted ABC's Face the Nation host Jake Tapper by refusing to denounce the support of white supremacist groups including the Ku Klux Klan. (Later on Sunday, Trump tweeted a perfunctory, annoyed disavowal.)

And Sessions has his own issues with failing to denounce the Klan. Arguably, it cost him a federal judgeship.

Back in 1986, 39-year-old Jefferson Beauregard Sessions III (then a federal prosecutor) was nominated to a federal judgeship by Ronald Reagan. As this 2002 New Republic article recounts in detail, his confirmation hearings before the Senate Judiciary Committee went ... poorly.

First, a witness said Sessions had called the ACLU and NAACP "un-American" — and Sessions confirmed that they really could be viewed that way on foreign policy. Then the witness said Sessions had (in the New Republic's words) "called a white civil rights lawyer a 'disgrace to his race' for litigating voting rights cases." Then this happened:

A black former assistant U.S. Attorney in Alabama named Thomas Figures testified that, during a 1981 murder investigation involving the Ku Klux Klan, Sessions was heard by several colleagues commenting that he "used to think they [the Klan] were OK" until he found out some of them were "pot smokers." Sessions claimed the comment was clearly said in jest. Figures didn't see it that way.

Sessions was not confirmed to the judgeship. He (eventually) went to the Senate, and the Senate Judiciary Committee, instead.

This isn't to say that either Trump or Sessions actively supports the Klan. But both of them have supporters who feel that white people are threatened in America, and who look favorably on times when white America was great. That ideology sometimes involves a romanticized idea of what white supremacist symbols (like the Klan or the Confederate battle flag) actually stood for.

So on the eve of a primary through the heart of the Deep South, Trump is simply doing what he needs to do to maintain his support — and having Sessions on his side can only bolster his cred.