Authorities have not alleged that they were involved in the attack, which took place across two floors in a classroom on Friday morning.

The gunman played the mass-shooting videos to others at a dinner earlier in the week, several US media outlets report, quoting an anonymous official briefed on the investigation.

A Twitter user appearing to match Alshamrani’s identity had also made a series of anti-US posts before the shooting, an online monitoring group says.

Image captionThe gunman has been officially named as Mohammed Alshamrani by the FBI

But US Defence Secretary Mark Esper said on Saturday that he would not label the incident “terrorism” at this point.

Speaking at the Reagan National Defense Forum in California, he said investigators must be allowed to do their work.

President Donald Trump later pledged to review foreign military training programmes in the US. More than 850 Saudi nationals are reported to be in the country for such activities.

What happened on Friday?

Authorities were alerted to the shooting at the Pensacola base at 06:51 (12:51 GMT).

It took place across two floors of a classroom building and ended when a sheriff’s deputy killed Alshamrani.

Eight people were also injured in the shooting, including two officers, who are expected to recover.

Family members of Joshua Kaleb Watson said he was shot several times but made it out of the building to alert first responders.

On Facebook, his brother Adam Watson wrote: “He died a hero and we are beyond proud but there is a hole in our hearts that can never be filled.”

Capt Tim Kinsella, the base’s commanding officer, said of the three sailors killed: “When confronted, they didn’t run from danger; they ran towards it and saved lives.”

Why were Saudis at the US base?

The Pensacola base has long offered aviation training to foreign military forces.

Saudi pilots started training there in 1995, alongside other personnel from Italy, Singapore and Germany.

Cpt Kinsella Jnr said that about 200 international students were enrolled in programmes there. According to its website, the base employs more than 16,000 military and 7,400 civilian personnel.

Alshamrani was a second lieutenant in the Saudi Air Force.

What has the reaction been?

Saudi Arabia is a key US ally in the Middle East and President Trump said the Saudi king called him after the attack to “express his sincere condolences and give his sympathies to the families and friends of the warriors who were killed”.

Mr Trump said King Salman told him that “this person in no way shape or form represents the feelings of the Saudi people who love the American people”.

The US president later said the Saudi leaders were “devastated” after the attack, adding: “I think they are going to help out the families very greatly.”