Riyadh (AFP) - Saudi Arabia sought to distance itself Saturday from a student who carried out a fatal shooting at an American naval base, as it seeks to repair its image of being an exporter of Islamic extremism.

The Saudi military trainee reportedly condemned the US as a "nation of evil" before going on a rampage Friday at Naval Air Station Pensacola in Florida, killing three people and wounding eight.

The shooting marks a setback in the kingdom's efforts to shrug off its longstanding reputation for promoting religious extremism after the September 11, 2001 attacks in which 15 of the 19 hijackers were Saudis.

The hashtag "Saudis stand with America" gained traction on social media after King Salman telephoned President Donald Trump to denounce the shooting as "heinous" and pledge cooperation with American officials to investigate the incident.

The king added in the phone call on Friday that the shooter, who was gunned down by police, "does not represent the Saudi people".

The family of the shooter, identified as Mohammed al-Shamrani, echoed the same sentiment.

The pro-government Okaz newspaper quoted one of his uncles, Saad al-Shamrani, as saying that his actions do not reflect the "humanity and loyalty of his family" to the kingdom's leadership.

Prince Khalid bin Salman, the king's younger son and the deputy defence minister, offered his "sincerest condolences" to the families of the victims.

"Like many other Saudi military personnel, I was trained in a US military base, and we used that valuable training to fight side by side with our American allies against terrorism and other threats," Prince Khalid said on Twitter.

"A large number of Saudi graduates of the Naval Air Station in Pensacola moved on to serve with their US counterparts in battlefronts around the world, helping to safeguard the regional and global security. (The) tragic event is strongly condemned by everyone in Saudi Arabia."

- 'Owe a debt' -

The incident is unlikely to affect Washington's close relations with Riyadh, with both governments seeking military and diplomatic cooperation to counter Shiite power Iran.

Story continues

Seeking to emphasise the close ties, many Saudis on social media highlighted American media reports about two exchange students from Saudi Arabia who drowned last year in Massachusetts after rushing into a river to rescue two small children.

But Florida Governor Ron DeSantis suggested Riyadh should offer compensation to the victims.

"The government of Saudi Arabia needs to make things better for these victims, and I think they're going to owe a debt here given that this is one of their individuals," DeSantis told US media.

Saudi citizens strongly rejected the view on social media, with one Twitter user saying: "The government of Saudi Arabia is not responsible for every single individual with a Saudi passport."

Relatives of the victims of the 2001 attacks are also suing Saudi Arabia for compensation even though Riyadh has strongly denied complicity in the attacks.

Saudi Arabia's de facto ruler Crown Prince Mohammed bin Salman has sought to project a moderate image of his austere kingdom, often associated in the West with jihadist ideology.

Prince Mohammed has promoted what observers call a de-emphasis on religion as he pursues a sweeping modernisation drive that has allowed mixed-gender music concerts and ended decades-long bans on cinemas and women drivers.

Saudi Arabia, which is home to Islam's holiest sites in Mecca and Medina and where the practice of other religions is banned, has hosted a flurry of representatives of various Christian traditions in recent months.

But the self-styled reformer has also faced global criticism for the kingdom's poor human rights record, including the jailing of multiple women activists, clerics and journalists.