The gunman in a deadly attack at a military base in Pensacola, Florida, last December was meticulous in his planning and had been radicalized overseas for at least five years, U.S. officials said Monday.

The FBI learned of the contacts between the gunman, Mohammed Saeed Alshamrani, and an al-Qaida operative after breaking the encryption on cellphones that had previously been locked.

Attorney General William Barr and FBI Director Chris Wray held a news conference to announce the developments in the shooting late last year at the Pensacola Naval Air Station, in which a Saudi Air Force officer killed three U.S. sailors and injured eight other people.

Alshamrani, who was killed by a sheriff’s deputy during the rampage at a classroom building, was undergoing flight training at Pensacola, where members of foreign militaries routinely receive instruction.

The Justice Department had previously asked Apple to help extract data from two iPhones that belonged to the gunman, including one that authorities say Alshamrani damaged with a bullet after being confronted by law enforcement. Wray said FBI agents were able to break the encryption without the help of Apple.

Law enforcement officials left no doubt that Alshamrani was motivated by jihadist ideology, saying he visited a New York City memorial to the attacks of Sept. 11, 2001, over the Thanksgiving holiday weekend and posted anti-American and anti-Israeli messages on social media just two hours before the shooting.

Separately, al-Qaida's branch in Yemen, released a video claiming the attack. The branch, al-Qaida in the Arabian Peninsula, or AQAP, has long been considered the global network's most dangerous branch and has attempted to carry out attacks on the U.S. mainland.

In January, U.S. officials announced that they were sending home 21 Saudi military students after an investigation revealed that they had had jihadist or anti-American sentiments on social media pages or had “contact with child pornography."

Barr said at the time that Saudi Arabia had agreed to review the conduct of all 21 to see if they should face military discipline and to send back anyone the U.S. later determines should face charges.

— This is a developing story. Please check back with AJC.com for updates.