President-elect Donald Trump has named Pam Bondi, the former attorney general of Florida, to be US attorney general just hours after Matt Gaetz withdrew his name from consideration.

Ms Bondi is a long-time ally of Mr Trump and was one of his lawyers during his first impeachment trial when he was accused — but not convicted — of abusing his power as he tried to condition US military assistance to Ukraine on that country investigating then-former vice president Joe Biden.

Ms Bondi was among a group of Republicans who showed up to support Mr Trump at his hush money criminal trial in New York which ended in May with a conviction on 34 felony counts. She has chaired the America First Policy Institute, a think tank set up by former Trump administration staffers.

“For too long, the partisan Department of Justice has been weaponised against me and other Republicans – Not anymore,” Mr Trump said in a social media post. “Pam will refocus the DOJ to its intended purpose of fighting Crime, and Making America Safe Again.”

Pam Bondi, former Florida Attorney General, speaks to reporters outside an election integrity volunteer training. (AP/Derik Hamilton)

Mr Trump’s son Donald Trump Jr told Fox Business on Sunday that the transition team had back-ups in mind for his controversial nominees should they fail to get confirmed.

The swift selection of Ms Bondi came about six hours after Mr Gaetz withdrew.

Mr Gaetz stepped aside amid continued fallout over a federal sex trafficking investigation that cast doubt on his ability to be confirmed as the nation’s chief federal law enforcement officer.

That announcement capped a turbulent eight-day period in which Mr Trump sought to capitalise on his decisive election win to force Senate Republicans to accept provocative selections like Mr Gaetz, who had been investigated by the Justice Department before being nominated last week to lead it.

The decision could heighten scrutiny on other controversial nominees, including Pentagon pick Pete Hegseth, who faces sexual assault allegations that he denies.

President-elect Donald Trump arrives for a campaign rally in  Arizona (AP/Evan Vucci)

“While the momentum was strong, it is clear that my confirmation was unfairly becoming a distraction to the critical work of the Trump/Vance Transition,” Mr Gaetz, a Florida Republican who one day earlier met with senators to win their support, said in a statement.

“There is no time to waste on a needlessly protracted Washington scuffle, thus I’ll be withdrawing my name from consideration to serve as Attorney General. Trump’s DOJ must be in place and ready on Day 1.”

In a social media post, Mr Trump said: “I greatly appreciate the recent efforts of Matt Gaetz in seeking approval to be Attorney General. He was doing very well but, at the same time, did not want to be a distraction for the Administration, for which he has much respect. Matt has a wonderful future, and I look forward to watching all of the great things he will do!”

Last week, Mr Trump named his personal lawyers Todd Blanche, Emil Bove and D John Sauer to senior roles in the department. Another possible attorney general contender, Matt Whitaker, was announced Wednesday as the US ambassador to Nato.