Trump said the shooter had a "violent history and possible obsession" with the White House.
A gunman was killed following a shootout with Secret Service agents close to the White House on Saturday, US President Donald Trump and law enforcement officials said.
The individual had pulled out a gun and began firing just after 6 pm on Saturday evening, in the area of 17th Street and Pennsylvania Avenue, Anthony Guglielmi, the US Secret Service's chief of communications, said in a statement.
Trump was in the White House at the time, but he was not impacted by the incident, per Guglielmi.
"Secret Service Police returned fire striking the suspect who was transported to an area hospital where he was pronounced deceased," the statement reads. "During the shooting one bystander was also struck by gunfire."
No officers were reported to have been injured.
In a post on Truth Social, Trump said the shooter had a "violent history and possible obsession" with the White House and thanked authorities for their "swift and professional action".
It "goes to show how important it is, for all future Presidents, to get, what will be, the most safe and secure space of its kind ever built in Washington, D.C.," Trump added.
Trump has been the target of a number of suspected assassination attempts in the last two years.
In April, a man was charged with one count of attempt to assassinate the US president after authorities say he stormed the White House correspondents’ dinner armed with guns and knives.