WASHINGTON (AFP)

A man accused of trying to open fire on a media gala attended by Donald Trump in Washington at the weekend was charged in court Monday with trying to assassinate the US president.

Cole Allen, 31, faces a sentence of up to life in prison if convicted of attempting to kill Trump during the White House Correspondents Association dinner at a hotel in the capital.

Allen, who wore a blue jumpsuit, was also charged with two firearms crimes. He did not enter a plea at the hearing in a federal court and was detained, pending his next court appearance.

Prosecutors told the Washington court that Allen was carrying a pump-action shotgun, a semi-automatic pistol and three knives when he tried to break through security at the Hilton, where the annual WHCA dinner has taken place for decades.

Several shots were fired before Allen was subdued in a chaotic encounter near a checkpoint. Allen never got close to Trump or the other guests attending the large-scale dinner event on a lower floor.

The California man's attack was the third attempt on 79-year-old Trump's life in two years. The White House has blamed a "left-wing cult of hatred" for inciting violence, singling out Democratic politicians who have accused Trump of trying to amass authoritarian powers.

Trump himself routinely breaks precedent with insults against opponents, the media, judges, foreign leaders and the head of the central bank.

On Saturday, Trump was rushed out of the venue by Secret Service agents after the sound of gunshots erupted. Video footage showed the gunman sprinting past a first line of security. No one was killed, but a bullet struck one agent's bulletproof vest, officials say.

In a television interview on Sunday evening, Trump was asked if he feared there would be casualties as Washington's government and media elite ducked for cover at the black-tie dinner downstairs.
"I wasn't worried. I understand life. We live in a crazy world," Trump said.

At the venue were Trump, First Lady Melania Trump, Vice President JD Vance, several cabinet members and top lawmakers and hundreds of guests.

Authorities say that shortly before the incident, Allen sent an email to family members explaining and apologising for his actions. He did not mention Trump by name, but said, "I am no longer willing to permit a paedophile, rapist and traitor to coat my hands with his crimes." Allen went on to say that "administration officials" are "targets, prioritised from highest-ranking to lowest."