WASHINGTON — The gunman in last year’s deadly shooting at a military base in Florida had been in touch with Al Qaeda for years and regularly spoke to the group’s operatives, including the night before the attack, the heads of the Justice Department and F.B.I. said on Monday, accusing Apple of costing them valuable time by refusing to help unlock the gunman’s phone.
The F.B.I. found that the gunman, Second Lt. Mohammed Saeed Alshamrani, a Saudi Air Force cadet training with the American military in Pensacola, had “significant ties” to Al Qaeda in the Arabian Peninsula before the attack and joined the Saudi military to carry out a “special operation,” Attorney General William P. Barr said at a news conference.
The F.B.I. discovered that Mr. Alshamrani had communicated with Qaeda leaders in the months and days before the shooting in December after it recently bypassed the security features on at least one of his two iPhones. Christopher A. Wray, the director of the F.B.I., said that the bureau had “effectively, no help from Apple,” but he would not say how investigators obtained access the phones.
The case has served as the latest skirmish in a continuing fight between the Justice Department and Apple pitting personal privacy against public safety. Both Mr. Barr and Mr. Wray castigated Apple for refusing to help bypass its encryption. Apple’s defiance allowed any possible co-conspirators to fabricate and compare stories, destroy evidence and to disappear, Mr. Wray said.
“It was clear at the time that the phones are likely to contain very important information,” Mr. Barr said, adding that President Trump had also asked Apple for help.
Apple did not immediately respond to a request for comment. It has argued that data privacy is a human rights issue and that if it were to develop a way to allow the American government into its phones, hackers or foreign governments like China could exploit the same tool.
Officials would not say that Al Qaeda directed Mr. Alshamrani to carry out the December shooting. But they emphasized his longstanding ties and communications with top Qaeda leaders that proved his relationship with the group went beyond simply being inspired to act based on watching YouTube videos or reading extremist propaganda.
The evidence obtained from Mr. Alshamrani’s phone showed that the Pensacola attack was “the brutal combination of years of planning and preparation.” Mr. Wray said.
Mr. Alshamrani paused to fire at his iPhone during a firefight with security officers and he was found with a second, badly damaged phone that the Saudi destroyed, leading investigators to conclude that the devices held important data.
In January, when Mr. Barr designated the shooting an act of terrorism, Apple refused a Justice Department request to help open the iPhones, setting off fears that the government would seek a court order to force the company to comply.
The department said that it sought Apple’s help in opening the phones only after other agencies, foreign governments and third-party technology vendors had failed, and it accused the company of slowing the investigation and allowing leads to go cold.
The night before the attack, Mr. Alshamrani had showed videos of mass shootings to guests at a dinner party, and he had posted anti-American, anti-Israeli and jihadist social media messages.
Three weeks after the shooting, Qassim al-Rimi, the leader of Al Qaeda in the Arabian Peninsula, said that his group directed Mr. Alshamrani to commit the murders in Pensacola. Mr. al-Rimi had a copy of what he said was Mr. Alshamrani’s will and messages that seemed to show the gunman had been in contact with the Yemeni-based group.
Soon after the recorded message was released, the United States confirmed that it had killed Mr. al-Rimi in a drone attack, a major blow to one of Qaeda’s last, vibrant branches.
While the F.B.I. has spent the last few years primarily trying to thwart international terrorism inspired by the Islamic State, Mr. Wray told lawmakers last year that Al Qaeda still wants to conduct “large-scale, spectacular attacks,” but is “likely to focus on building its international affiliates and supporting small-scale, readily achievable attacks”
U.S. counterterrorism efforts have degraded the capabilities of Al Qaeda in Yemen and the Pakistan-Afghanistan region but the Pensacola shooting still shows the group’s ideology can inspire attacks. In 2016, authorities warned of a vague Qaeda threat.
Even though the casualty count was relatively low by Qaeda standards, simply “pulling off a successful attack on U.S. soil can provide Al Qaeda and its affiliates with a momentum boost and allow the group bragging rights over the Islamic State, which is important in terms of recruitment, prestige, and propaganda,” Colin P. Clarke, a senior fellow at the Soufan Center, a New York-based research organization, said in an email on Monday.
“This illustrates just how dangerous one operative can be,” Mr. Wray said.
Even though Mr. Alshamrani was thought to have operated alone, the government expelled 21 other Saudi students who were training with the American military, some of whom had links to extremist movements. After announcing the expulsions, Mr. Barr said that the Saudi government had cooperated with the investigation.
Saudi Arabia has a complicated relationship with Yemen, where it has been embroiled in a lethal, yearslong military battle to end Iranian influence there. Amid the airstrikes, the Islamic State and Al Qaeda in the Arabian Peninsula have seized territory and carried out their own deadly attacks.
Mr. Alshamrani’s ability to train on the base as part of the U.S. military raises a host of thorny issues, including how the Defense Department screens potential recruits from Saudi Arabia. Mr. Barr said that the screening and vetting process in this case was insufficient, and Defense Secretary Mark T. Esper pledged in a statement to keep up additional safeguards that the Pentagon had already installed.
After the shooting, the Defense Department ordered a stop to all international military student training at American installations. In January, Mr. Esper imposed tighter restrictions on the use of firearms and access to government facilities for international military students. He approved the continuous monitoring of international students while they are enrolled in U.S.-based training programs.
The shooting also reignited the debate about when a technology company should be expected to help the government obtain information from encrypted messaging apps that can only be found if you can bypass the password and other security features. Apple routinely gives law enforcement lawful access to information that its users store in their iCloud accounts.
Though it was not clear how the F.B.I. got into Mr. Alshamrani’s iPhones, there are indications that Apple’s security is not as uncrackable as it used to be.
Last week, Zerodium, a company that acquires and sells weaknesses in smartphone encryption to American agencies to hack into those devices, announced it has a surplus of such exploits for Apple’s iOS mobile operating system.
The firm’s claims undermine the Justice Department’s and the F.B.I.’s assertions that Apple’s security is preventing lawful interception of data collection, especially on older model phones. Mr. Alshamrani had an iPhone 7 and an iPhone 5.
But Mr. Barr has maintained one of the department’s “highest priorities” is to find a way to get technology companies to help law enforcement gain lawful access to encrypted technology.
Nicole Perlroth and Eric Schmitt contributed reporting.