Twenty-one Saudi military cadets undergoing training in the United States will be sent back to Saudi Arabia following an investigation into the fatal shooting of three Americans by a Saudi officer at a Florida naval base that US Attorney General William Barr on Monday branded as an "act of terrorism".

Saudi Air Force Second Lieutenant Mohammed Saeed Alshamrani, 21, killed three sailors and wounded eight others before being fatally shot by a deputy sheriff during the December 6 incident at the facility in Pensacola, Florida, an official said.

The attack brought fresh complications to US-Saudi relations at a time of heightened tensions between the US and Iran, Saudi Arabia's regional rival.

More:

"This was an act of terrorism," Barr said. "The evidence showed that the shooter was motivated by jihadist ideology. During the course of the investigation, we learned that the shooter posted a message on September 11 of this year stating, 'The countdown has begun.'"

Barr added that Alshamrani also visited the New York City memorial to the victims of the September 11, 2001, attacks on the US and posted anti-American, anti-Israeli and "jihadi messages" on social media, including two hours before the attack.

Barr said 21 Saudi cadets were "disenrolled from their training curriculum" in the US military and would leave the US later on Monday after an investigation showed they either had child pornography or social media accounts containing "jihadi messages" and anti-American content.

During a news conference, Barr - the top US law enforcement official - said there was no evidence of assistance by other Saudi trainees or that any of them had knowledge in advance of the December shooting attack.

Saudi Arabia provided "complete and total support" to the American investigation of the incident, Barr said.

Barr added one Saudi individual had "a significant number of such images," while 14 others "had one or two images, in most cases posted in a chat room by someone else or received over social media.

The "derogatory information" fell short of the standard for triggering US criminal charges, Barr said.

"However, the kingdom of Saudi Arabia determined that this material demonstrated conduct unbecoming an officer in the Royal Saudi Air Force and in the Royal Navy," Barr said, adding that "the 21 cadets have been disenrolled from their training curriculum in the US military and will be returning to Saudi Arabia later today."