The Federal Bureau of Investigation has identified 20-year-old Thomas Matthew Crooks as the "subject involved" in the attempted assassination of former US president Donald Trump.
Crooks from Bethel Park, Pennsylvania was registered as a Republican, according to the state's voter records.
The US Secret Service confirmed that Crooks was shot dead by agents after he opened fire from the roof of a building about 140 metres from the stage where Trump was speaking at the campaign rally in Butler, Pennsylvania.
An AR-15-style semiautomatic rifle was recovered near Crooks' body.
Special agent in charge of the FBI's Pittsburgh field office Kevin Rojek told a media conference that authorities had not yet identified a motive.
Rojek said it was "surprising” the gunman was able to open fire on the stage before the Secret Service killed him.
But when asked if there was a failure of security, he said they were "not gonna make that assessment" with an active investigation.
A rally attendee died and two were critically injured in the incident, the FBI said.
The Trump campaign later said he was "doing well" and appeared to have suffered no major injury besides a wound on his upper right ear.
After the shooting, a defiant Trump said he will remain "resilient" and is 'looking forward' to appearing at the Republican national convention.
"Thank you to everyone for your thoughts and prayers yesterday, as it was God alone who prevented the unthinkable from happening," he wrote on the Truth Social platform.
"We will fear not, but instead remain resilient in our faith and defiant in the face of wickedness.
"Our love goes out to the other victims and their families. We pray for the recovery of those who were wounded, and hold in our hearts the memory of the citizen who was so horribly killed.
"In this moment, it is more important than ever that we stand united, and show our true character as Americans, remaining strong and determined, and not allowing evil to win.
"I truly love our country, and love you all, and look forward to speaking to our great nation this week from Wisconsin. DJT"
In a statement posted on X, the US Secret Service said the shooter fired multiple shots toward the stage from an elevated position outside of the rally," the statement said.
Trump, 78, had just started his speech when the gunfire began.
As the shots rang out, Trump grabbed his right ear with his hand, then dropped to his knees behind the podium before Secret Service agents swarmed and covered him.
He emerged about a minute later, and could be heard saying "wait, wait," before agents ushered him to a vehicle.
The Republican candidate pumped his fist in the air as he was surrounded by security and mouthed the words, "Fight! Fight! Fight!"
President Joe Biden released a statement, expressing concern about the "sick" assassination attempt and saying he was "grateful" to hear that Trump was safe.
"I have been briefed on the shooting at Donald Trump’s rally in Pennsylvania. I’m grateful to hear that he’s safe and doing well," he said.
"I’m praying for him and his family and for all those who were at the rally, as we await further information. Jill and I are grateful to the Secret Service for getting him to safety.
"There’s no place for this kind of violence in America. We must unite as one nation to condemn it. It's sick, it's sick".
Ron Moose, a Trump supporter who was in the crowd, described the chaos during the event.
"I heard about four shots and I saw the crowd go down and then Trump ducked also real quick. Then the Secret Service all jumped and protected him as soon as they could. We are talking within a second they were all protecting him."
The BBC interviewed a man who described himself as an eyewitness, saying he saw a man armed with a rifle crawling up a roof near the event.
The person told the BBC he and the people he was with started pointing at the man, trying to alert security.
The attack was the most serious attempt to assassinate a president or presidential candidate since Ronald Reagan was shot in 1981.
with AP, PA and DPA