Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

The fatal attack on a naval base in Pensacola, Florida, last month by a Saudi national who was in the U.S. for military training was an act of terrorism motivated by jihadist beliefs, officials said.

Evidence showed that the gunman held anti-American and anti-Israeli views, which he posted on social media, including just hours before the Dec. 6 attack, Attorney General William Barr said Monday.

"This was an act of terrorism," Barr said. "The evidence shows the shooter was influenced by jihadist ideology."

The gunman was identified as Mohammed Saeed Alshamrani, a member of the Saudi Air Force, after the attack left three service members dead. Investigators did not offer a motive. Alshamrani died after exchanging gunfire with sheriff's deputies who responded to the shooting.

Eight Americans were injured in the attack, which lasted about 15 minutes.

Authorities said there was no evidence that Alshamrani acted with the assistance of other individuals or groups, though the government is working to unlock two Apple iPhones belonging to him.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"During the gunfight with the first responders, the shooter disengaged long enough to place one of his phones on the floor and shoot a single round into the device," Barr said. "It also appears the other phone was damaged."

The FBI's crime lab has been able to reconstruct the phones, but faces serious encryption challenges in collecting evidence off the devices. Investigators have obtained a warrant to search the phones but Apple has "not given any substantive assistance" to the government in bypassing the phones' security.

Barr would not comment on whether the government plans to take Apple to court to try to force the company's cooperation.

In a statement, Apple said that it learned about the government’s inability to access either phone only a week ago. The company said it was subpoenaed for information from the second phone two days later — a request that it said it responded to “within hours.”

“We are continuing to work with the FBI, and our engineering teams recently had a call to provide additional technical assistance,” the statement said. “Apple has great respect for the Bureau's work, and we will work tirelessly to help them investigate this tragic attack on our nation.”

The statement added that Apple had quickly complied with several earlier requests for access to iCloud backup material, account information and transactional data.

“The queries resulted in many gigabytes of information that we turned over to investigators,” the company said. “In every instance, we responded with all of the information that we had.”

The Pensacola Naval Air Station main gate following a shooting on Dec. 6, 2019 in Pensacola, Fla. Josh Brasted / Getty Images

Alshamrani was scheduled to complete a three-year U.S. Air Force Foreign Military Sales training program in August. The training, which includes English language coursework and aviation and pilot instruction, was funded by Saudi Arabia.

At least 21 other Saudi nationals who were in the country for military training were found to have possessed "derogatory material." Investigators found that 17 of the nationals had jihadist or anti-American content and at least 15 of them had "some kind of contact with child pornography," Barr said.

The Kingdom of Saudi Arabia has unenrolled the 21 members from their programs and will be reviewing each case under the country's own military and criminal codes, according to the attorney general.

"Further, the kingdom has assured us that if we later decide to charge any of those being sent back to Saudi Arabia in connection with this counterterrorism investigation, they will be returned for trial," Barr said.

Barr added that the kingdom has cooperated with the investigation and assured the United States that it will be given access to any person or any documents needed in the case.