WASHINGTON (Reuters) - Saudi Arabia will withdraw 21 cadets receiving military training in the United States following a U.S. investigation into a Saudi officer’s fatal shooting of three Americans at a Florida naval base that U.S. Attorney General William Barr on Monday branded an act of terrorism.

The Dec. 6 attack further complicated U.S.-Saudi relations at a time of heightened tensions between the United States and Iran, Saudi Arabia’s regional rival. A deputy sheriff shot dead the gunman, Saudi Air Force Second Lieutenant Mohammed Saeed Alshamrani, in the Pensacola, Florida, incident.

Barr provided previously undisclosed details about Alshamrani’s actions before the shooting.

Barr said 21 Saudi cadets were “disenrolled from their training curriculum” in the U.S. military and would leave the United States later on Monday after an investigation showed they either had child pornography or social media accounts containing Islamic extremist or anti-American content.

He indicated that it was Saudi Arabia that withdrew the cadets, rather than the United States formally expelling them, and said the Saudi authorities told him they would consider filing criminal charges against them. A Justice Department official, briefing reporters on condition of anonymity, said U.S. officials agreed with the decision to withdraw them.

During a news conference, Barr - the top U.S. law enforcement official - said there was no evidence that Alshamrani had received assistance from other Saudi trainees or that any of them had knowledge in advance of the attack.

Three American sailors were killed and eight other people were wounded in the attack at the Pensacola Naval Air Station.

“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 Sept. 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 Sept. 11, 2001, attacks on the United States - carried out by Saudi hijackers for the Islamist militant group al Qaeda - and posted anti-American, anti-Israeli and jihadi messages on social media, including two hours before the attack.

U.S. Attorney General William Barr announces the findings of the criminal investigation into the Dec. 6, 2019, shootings at the Pensacola Naval Air Station in Florida during a news conference at the Justice Department in Washington, U.S., January 13, 2020. REUTERS/Tom Brenner

Apple Inc AAPL.O has not been helpful to date in working with the FBI to get Alshamrani's two cellphones unlocked, Barr said. He added the FBI largely had exhausted its own efforts to unlock the phone.

In a statement, Apple rejected the assertion that it had not provided substantial assistance in the investigation.

The company said it had responded promptly to multiple FBI requests for information starting on the day of the attack, turning over “many gigabytes of information” to the investigators.

Barr said one Saudi individual had “a significant number” of child pornography 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.” A total of 17 - including some of those with child pornography images - had social media accounts containing some jihadi or anti-American content, Barr said.

The “derogatory information” fell short of the standard for triggering U.S. criminal charges, Barr said.

‘CONDUCT UNBECOMING AN OFFICER’

“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.

Saudi Arabia gave “complete and total support” in the U.S. counterterrorism investigation and ordered all Saudi trainees to cooperate, Barr said, adding that the kingdom had given assurances that it would return for trial any of the 21 if U.S. prosecutors decide to charge them in connection with this counterterrorism investigation.

The U.S. military relationship with Saudi Arabia has come under heightened scrutiny in the U.S. Congress over the war in Yemen and Saudi Arabia’s killing of Washington Post columnist Jamal Khashoggi in 2018.

President Donald Trump has expressed doubts about a CIA assessment that Prince Mohammed ordered the killing of Khashoggi, a U.S. resident and a critic of the crown prince, and argued that Washington must not risk its alliance with Riyadh, the cornerstone of U.S. security policy in the Gulf and regarded as a regional counterweight to Iran.

The Pensacola attack prompted the Pentagon to halt operational training for some 850 visiting Saudi military personnel as part of a “safety stand-down” in the aftermath of the shooting. The Pentagon said on Dec. 19 that it had found “no information indicating an immediate threat” after reviewing the visiting Saudis following the shooting.