President Trump on Friday abruptly reversed American policy toward Libya, issuing a statement publicly endorsing an aspiring strongman in his battle to depose the United Nations-backed government.

The would-be strongman, Khalifa Hifter, launched a surprise attack on the Libyan capital, Tripoli, more than two weeks ago. Relief agencies said Thursday that more than 200 people had been killed in the battle, and in recent days Mr. Hifter’s forces have started shelling civilian neighborhoods.

Secretary of State Mike Pompeo said in a statement a few days after Mr. Hifter’s militia began its attack that “the administration at the highest levels” had made clear that “we oppose the military offensive” and “urge the immediate halt to these military operations.” Most Western governments and the United Nations have also condemned the attack and demanded a retreat.

Mr. Trump, however, told Mr. Hifter almost the opposite, the White House said Friday.

A militia leader who has given himself the title of Field Marshal, Mr. Hifter, 75, has long sought to portray his fight for power over Libya — including his advance on Tripoli — as a battle against “terrorism.” In the statement on Friday the White House said Mr. Trump had called Mr. Hifter on Monday to endorse that campaign.