Attorney General William P. Barr said Monday that the December shooting that killed three U.S. sailors on a Florida base was an act of terrorism, as officials revealed harrowing new details about the 15-minute rampage and publicly called out Apple Inc. to help them unlock the killer’s phones.

At a news conference to discuss the results of the FBI’s investigation into the shooting at Naval Air Station Pensacola, Barr said investigators had found evidence that Ahmed Mohammed al-Shamrani, a Royal Saudi Air Force member training at the base, was motivated by “jihadist ideology” and had posted anti-American messages on social media about two hours before his attack.

FBI Deputy Director David Bowdich said that during the attack, Shamrani fired shots at pictures of President Trump and a past U.S. president, and witnesses at the scene said he made statements critical of American military actions overseas. Bowdich said that while Shamrani did not seem to be inspired by one specific terrorist group, he harbored anti-American and anti-Israeli views and felt “violence was necessary.” Bowdich said the gunman’s social media comments echoed those of Anwar al-Awlaki, a radical Yemeni American cleric tied to the terrorist group al-Qaeda who was killed in a drone strike in 2011.

Monday’s announcement offered the most definitive account of the gunman’s actions and thinking. Bowdich said investigators had interviewed more than 500 people — including witnesses, base personnel and friends and classmates of the shooter — and collected more than 42 terabytes of digital information.

But investigators have been stymied in trying to access two key pieces of evidence — the gunman’s iPhones. Standing before giant photographs of two severely damaged devices, the attorney general publicly urged Apple to act.

“So far, Apple has not given us any substantive assistance,” Barr said, though aides later clarified that Apple had, in fact, given investigators access to cloud data linked to the gunman. “This situation perfectly illustrates why it is critical that investigators be able to get access to digital evidence once they have obtained a court order.”

Barr did not say whether the Justice Department would seek a court order to force Apple’s compliance. The department filed legal papers on a similar case in 2016, but the issue was never resolved by a higher court.

Officials said Shamrani intentionally fired a round into one of the phones during his rampage.

In a lengthy statement, Apple disputed the attorney general’s description of its role, saying the company began responding within hours of the first FBI request on Dec. 6 and has turned over “many gigabytes” of data in the case.

“Our responses to their many requests since the attack have been timely, thorough and are ongoing,” the company said. “The FBI only notified us on January 6th that they needed additional assistance — a month after the attack occurred. . . . Early outreach is critical to accessing information and finding additional options.”

ACLU lawyer Jennifer Granick said the government’s demand to Apple “would weaken the security of millions of iPhones, and is dangerous and unconstitutional. . . . There is simply no way for Apple, or any other company, to provide the FBI access to encrypted communications without also providing it to authoritarian foreign governments and weakening our defenses against criminals and hackers.”

Even without the phone data, investigators were able to review Shamrani’s social media postings, which were critical to the officials’ determination.

In declaring the incident terrorism, Barr noted that on Sept. 11, Shamrani posted a message on social media saying, “The countdown has begun.” Over the Thanksgiving weekend, Barr said, Shamrani visited the memorial in New York City to those killed in the Sept. 11, 2001, terrorist attacks. Fifteen of the 19 hijackers who carried out those attacks were Saudis.

Barr said that while it was initially reported that Shamrani arrived to the shooting with others, who filmed it, those accounts turned out to be incorrect. The shooter, he said, arrived alone, though other cadets who happened to be in the area did film the ensuing commotion.

Bowdich said the incident lasted about 15 minutes, with authorities intervening to stop the attack after about eight minutes. Barr singled out sailor Ryan Blackwell, who he said — despite having been shot five times — jumped on top of a fellow service member to prevent her from being shot and helped others get to safety.

The gunman, who used a semiautomatic handgun he purchased legally via an exception that allows non-U.S. citizens with hunting licenses to do so, was fatally shot by a sheriff’s deputy.

Bowdich said investigators had not found evidence that the shooter acted with anyone else — though officials said they had uncovered troubling conduct by other Saudi military members training in the United States. Justice Department officials, speaking on the condition of anonymity to discuss the diplomatically sensitive matter, said that while officials were confident Shamrani had no U.S.-based co-conspirator, they were still interested in potential interactions he might have had with those in Saudi Arabia.

Barr said investigators had found evidence that 17 Saudis had through social media shared ­jihadist or anti-American material and 15 — including some of those who had shared anti-American material — were found to have had contact with or possessed child pornography.

Barr said only one of those people had a “significant number” of images, and U.S. attorneys had reviewed each case and determined such people would not normally be charged with federal crimes. He said 21 cadets from Saudi Arabia had been disenrolled from their training and would be returning to the kingdom later Monday. Justice Department officials said 12 were from the Pensacola base, and nine were from other military bases.

U.S.-Saudi relations remain strained after the 2018 killing of Jamal Khashoggi, a Saudi journalist and Washington Post columnist — in the Saudi consulate in Istanbul by men allegedly with close ties to the highest levels of the Saudi government.

Justice Department officials said they had received an unprecedented level of cooperation from the Saudi government in the Pensacola case.

In a statement, the Embassy of the Kingdom of Saudi Arabia said: “The disturbed and radicalized individual who carried out this terrible attack acted alone. He does not represent the hundreds of thousands of Saudis who have lived, studied and trained in the United States over the past several decades, nor does his heinous act represent the values of Saudi Arabia. . . . Saudi Arabia will continue to cooperate with US authorities should they require additional information.”

Barr said the cadets’ anti-American posts were “not enough” to constitute a violation of law. There was no evidence they were affiliated with terrorist activity or a particular group, he said, and U.S. attorneys had independently determined the child porn did not warrant charges. Justice Department officials said the most significant case involved a cadet who possessed more than 100 images of child porn and had searched terms for child porn, according to his browser history — but even that fell below the normal threshold for a case deemed worthy of prosecution by a U.S. attorney’s office.

Barr stressed the importance of military partnerships, such as the one that allowed the Saudi cadets to train in the United States, and said the Saudi government had been cooperative. But he said more vetting of prospective trainees was needed.

“I think we’ve identified that vetting should be improved,” Barr said.

The Justice Department announcement appeared to settle many of the questions surrounding the Pensacola attack, while leaving one large issue unresolved — the potential battle over the dead killer’s phones.

The FBI’s top lawyer, Dana Boente, sent a letter to Apple last week asking for the company’s help to open the two iPhones.

For years, Apple has resisted any efforts to alter the encryption on its phones to make it possible for the company to give government investigators access to the data on such phones, saying that doing so would weaken the security of all its customers’ devices.

“Even though the shooter is dead, the FBI, out of an abundance of caution, has secured court authorization to search the contents of the phones in order to exhaust all leads in this high priority national security investigation,” Boente wrote to the company.

“Unfortunately, FBI has been unable to access the contents of the phones,” the letter said, even after asking private technology experts whether they could help agents crack them. “None of those reachouts has shown us a path forward.”

Asked Monday whether the FBI’s technical experts on cellphones had agreed with the decision to send the letter pressing Apple to open the phones, an FBI spokesperson said the bureau’s “technical experts — as well as those consulted outside of the organization — have played an integral role in this investigation. The consensus was reached, after all efforts to access the shooter’s phones had been unsuccessful, that the next step was to reach out to start a conversation with Apple.”

Apple and other companies have said that encryption on phones is an important safeguard protecting millions of consumers against hackers and other criminals.

The courts have yet to rule on whether companies such as Apple can be forced to change their business practices to give law enforcement agents access to phones and other devices.

Kareem Fahim contributed to this report.

This story was updated to include a statement from the FBI addressing questions about the bureau’s decision to seek assistance from Apple.