Media playback is unsupported on your device Media caption Meet the outsider who made Trump eat his words

US President Donald Trump has deleted several tweets endorsing a candidate he backed in an Alabama election after he crashed to defeat on Tuesday.

"Luther Strange has been shooting up in the Alabama polls since my endorsement," Mr Trump wrote in one now-removed post.

He campaigned for Mr Strange, but could not save him from defeat by ultraconservative firebrand Roy Moore.

The underdog's victory has sent shockwaves through Washington.

Things Republican Roy Moore believes

In one now-deleted Tweet, the president said Mr Strange "will never let you down!" according to news website ProPublica, which documents Mr Trump's posts.

In another, the president said "vote today for 'Big Luther'".

A lesson for the president

Analysis:By Anthony Zurcher, BBC North America reporter

Alabama Senator Luther Strange is disappearing down the memory hole.

As in George Orwell's 1984, where politically inconvenient information is scrubbed from the records, Donald Trump is airbrushing over past support for the soon-to-be-former senator.

It's just part of the president's efforts to mend fences with his Make America Great Again base and their more impassioned advocates.

Getting back in favour with Mr Moore's supporters shouldn't be too hard for Mr Trump, given there were few who seemed to believe his heart was in the Strange endorsement.

They thought the president was mistaken or being misled, and he would eventually come around. It didn't take long.

If there's a lesson the president will take from all this, it may be that he shouldn't try too hard to push his supporters in a direction they don't want to go.

And if you're a Washington politician seeking re-election next year, it's best to assume you're going to be on your own.

Early on Wednesday, Mr Trump changed his tune to congratulate Mr Moore on his victory.

"Sounds like a really great guy who ran a fantastic race. He will help to #MAGA!" he tweeted, referring to his "Make America Great Again" catchphrase.

The Republican president has been known previously to occasionally delete tweets, most often replacing them after correcting spelling errors or other mistakes.

Some watchdog groups have criticised the deletions, saying that the tweets are government records that must be preserved for the historical record.

Mr Moore rode a wave of support in the Republican primary from the same grassroots conservative movement that helped elect Mr Trump.

A political fund closely linked to Senate Republican leader Mitch McConnell spent nearly $9m on Mr Strange's campaign.

But Mr Moore derided his opponent as an "establishment lackey".

With all 67 counties reporting, the outspoken evangelical Christian led the incumbent by 55% to 45%.

Mr Trump and Vice-President Mike Pence both appeared with Mr Strange at rallies in Alabama.

Skip Twitter post by @realDonaldTrump Congratulations to Roy Moore on his Republican Primary win in Alabama. Luther Strange started way back & ran a good race. Roy, WIN in Dec! — Donald J. Trump (@realDonaldTrump) September 27, 2017 Report

The president had tweeted support for him at least 10 times.

During a campaign appearance for Mr Strange last week, Mr Trump told the crowd "I might have made a mistake" in endorsing the former Alabama attorney general.

Mr Strange was appointed to the Alabama Senate seat after Jeff Sessions joined the Trump administration as attorney general.

Image copyright Getty Images Image caption Mr Moore said of the vote: "God has put me in this election at this time, and all the nation is watching"

A White House aide told CNN on Wednesday that the president felt "embarrassed" by Mr Strange's loss.

Political website Axios reports that Mr Trump blames Mr McConnell and "has taken to physically mocking" him.

Mr Moore, 70, is best known for twice losing his position on the Alabama Supreme Court.

He was de-benched the first time for refusing to remove a Ten Commandments monument from the courthouse and again for refusing to issue same-sex marriage licences.

Mr Moore is now the heavy favourite for Alabama's special election in December against a Democrat.

Alabama has not elected a Democrat to the Senate in a quarter of a century.