The gunman’s phone revealed the terror link, the FBI and Department of Justice said.
The attack in Pensacola, Florida killed three US sailors and injured eight.
Prosecutors criticised Apple for refusing to unlock the gunman’s phones, which authorities took months to hack.
The attack led to the expulsion of 21 Saudi military pupils who had been studying at the base with the attacker.
According to the FBI, the gunman, who was killed by authorities after shooting 11 people, had been radicalised before arriving Florida for a three-year aviation course the US navy hosts for allied foreign servicemen.
Records revealed that he had been in active contact with AQAP, an off-shoot of al-Qaeda based in Yemen, up to the shooting, including talking about plans to carry out a “special operation” for them.
The group’s leader, Qasim al-Raymi, was confirmed in February to have been killed during a US operation. AQAP had released an audio message earlier that month with Raymi’s voice, in which he said the group was behind the naval base shooting.
FBI Director Christopher Wray said that gunman was “more than inspired” by AQAP, sharing tactics and “co-ordinating” with the group on plans for attack.
The attack strained US-Saudi relations and led the Defence department to pause…