A Saudi pilot who killed three people on a US airbase in Florida had called America a "nation of evil" and quoted Osama bin Laden in social media posts hours before opening fire, according to an extremism monitoring group.
The killer, a member of the Royal Saudi Air Force who had been training at the Pensacola airbase, was shot dead by a sheriff's deputy.
He has not been formally identified, although Reuters quoted two unnamed officials as saying he was Second Lieutenant Mohammed Saeed Alshamrani.
Police have said they are investigating whether the attack was terror-related. It is believed he was acting alone although other Saudi personnel on the airbase have been questioned in connection with the attack,
The SITE Intelligence Group, which tracks Islamist extremism online, said that he had posted on Twitter about US wars in the Middle East shortly before the shootings.
He reportedly said that he hated the American people for "committing crimes not only against Muslims but also humanity", as well as criticising Israel and quoting Bin Laden, the former Al Qaeda leader killed by US special forces in 2011.
One of the victims has been identified as Joshua Kaleb Watson, a 23-year-old graduate of the US Naval Academy from Enterprise, Alabama.
In a Facebook post, his brother Adam wrote: "Joshua Kaleb Watson saved countless lives today with his own.
"After being shot multiple times he made it outside and told the first response team where the shooter was and those details were invaluable.
"He died a hero and we are beyond proud but there is a hole in our hearts that can never be filled."
An uncle of the man identified as the shooter, Saad bin Hantim Alshamrani, told CNN that his nephew was 21 and was "likeable and mannered towards his family and the community".
He said his nephew "has his religion, his prayer, his honesty and commitments" but that if he had carried out the killings, he would be "accountable before God".
Florida Senator Rick Scott said the shooting was an act of terrorism "whether this individual was motivated by radical Islam or was simply mentally unstable".
He said it was "clear that we need to take steps to ensure that any and all foreign nationals are scrutinised and vetted extensively before being embedded with our American men and women in uniform".
He tweeted: "King Salman of Saudi Arabia just called to express his sincere condolences and give his sympathies to the families and friends of the warriors who were killed and wounded in the attack that took place in Pensacola, Florida....
"....The King said that the Saudi people are greatly angered by the barbaric actions of the shooter, and that this person in no way shape or form represents the feelings of the Saudi people who love the American people."
Commentators observed that the tone of the president's tweets was consistent with his positive attitude towards the kingdom, and contrasted it with some of his policies towards other Muslim-majority nations, such as his 2017 travel ban against seven countries.
Mr Trump has championed his good relationship with Saudi Arabia, despite the murder of Washington Post journalist Jamal Khashoggi in the Saudi consulate in Istanbul. In October he said he was sending 2,800 more US troops to bolster Saudi defences, following an attack -- apparently ordered by Iran -- on the Abqaiq oil facility the previous month.
Facing criticism for removing US troops from Syria while sending more to Saudi Arabia, the president said the difference was that Riyadh was paying for the protection.
The Pensacola shooting was the second mass killing at a US naval base in a matter of days.
On Wednesday a sailor at the Pearl Harbor naval shipyard in Hawaii, identified as 22-year-old Antonio Romero, opened fire on colleagues, killing Vincent J Kapoi, 30, and Roldan A Agustin, 49, before killing himself.
A motive for the attack was being investigated.
Agencies contributed to this report