Donald Trump has not had much luck picking Alabama elections.

Earlier this year, Mr Trump weighed in on a Republican primary launched by his decision to tap former Alabama Senator Jeff Sessions to be his Attorney General, thus opening up a Senate seat.

Breaking with his former adviser Steve Bannon, the President chose the establishment candidate, Luther Strange.

Voters disagreed, rejecting the more moderate Mr Strange in favour of staunch conservative Roy Moore. The decision drew a swift pivot from Mr Trump, who called Mr Moore “a really great guy who ran a fantastic race”. Missives praising Mr Luther vanished from his Twitter timeline.

As sexual misconduct allegations engulfed Mr Moore’s campaign, Mr Trump was initially more muted in his support, though he cast doubt on the veracity of the accusers’ accounts (Mr Moore has called the claims against him false, saying “I never engaged in sexual misconduct).

But as the election drew closer, Mr Trump opted for a full-throated embrace of Mr Moore — breaking with Republican senators and leaders who had distanced themselves from a candidate many had come to view as toxic.

Alabama Senate race: Roy Moore vs Doug Jones Show all 12 1 /12 Alabama Senate race: Roy Moore vs Doug Jones Alabama Senate race: Roy Moore vs Doug Jones Democratic senatorial candidate Doug Jones speaks to reporters after voting Getty Images Alabama Senate race: Roy Moore vs Doug Jones Republican Senatorial candidate Roy Moore (L) and his wife Kayla ride their horses to the polling station to vote AFP/Getty Images Alabama Senate race: Roy Moore vs Doug Jones David Watson waves in a Santa suit as he holds a Doug Jones sign AP Alabama Senate race: Roy Moore vs Doug Jones Republican Senatorial candidate Roy Moore speaks to the media as his wife Kayla (R) looks on AFP/Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Alabama Senate candidate Doug Jones casts his vote at Brookwood Baptist Church REUTERS Alabama Senate race: Roy Moore vs Doug Jones Roy Moore speaks to the media after he rode in on a horse to vote AP Alabama Senate race: Roy Moore vs Doug Jones Democratic candidate Doug Jones greets supporters after casting his ballot AP Alabama Senate race: Roy Moore vs Doug Jones Republican Senate candidate Roy Moore departs on horseback after he cast his ballot in Gallant REUTERS Alabama Senate race: Roy Moore vs Doug Jones Voters wait in line to cast their ballot at a polling station setup in the St Thomas Episcopal Church Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Senatorial candidate Doug Jones (L) greets voters outside of a polling station at the Bessemer Civic Center Getty Images Alabama Senate race: Roy Moore vs Doug Jones Voters exit after casting their ballots at a polling station setup in the Fire Department Getty Images Alabama Senate race: Roy Moore vs Doug Jones Democratic Alabama U.S. Senate candidate Doug Jones speaks with the media after casting his vote at Brookwood Baptist Church Reuters

On Twitter and in speeches, Mr Trump lauded the candidate and warned that electing his Democratic rival, Doug Jones, would undermine the Republican agenda in Congress.

“The people of Alabama will do the right thing,” Mr Trump predicted in an Election Day tweet. “Doug Jones is Pro-Abortion, weak on Crime, Military and Illegal Immigration, Bad for Gun Owners and Veterans and against the WALL. Jones is a Pelosi/Schumer Puppet. Roy Moore will always vote with us. VOTE ROY MOORE!”

If the “right thing” is defined as “vote for Roy Moore,” then Mr Trump was proved wrong again. Mr Jones prevailed in a tight race, and now Mr Trump will face a steeper climb to advancing his platform.