The shooter was identified as Mohammed Alshamrani, a Saudi national and member of the country's air force who was in the U.S. for flight training, law enforcement officials familiar with the investigation told ABC News. Investigators are trying to determine whether the shooting was terror-related, the officials said.
The shooting took place at one of the classroom buildings on the base, officials said. Officers with the Escambia County Sheriff's Office arrived on the scene and fatally shot the suspect after exchanging gunfire.
Three people, including the shooter, were pronounced dead on scene, police said. One victim was taken to the hospital and died from injuries.
Eight others injured in the shooting were transported to Baptist Hospital, police said. The condition of those victims has not been released.
"Walking through the crime scene was like being on the set of a movie," Escambia County Sheriff David Morgan told reporters earlier in the day, adding, "The threat has been negated, our community is secured at this time."
None of the victims have been identified.
In a later interview with ABC News' Eva Pilgrim, Morgan confirmed the suspect used a semi-automatic handgun with an extended magazine.
Morgan described a "war zone," a crime scene that could "days to process."
At the scene, "a tremendous number of rounds fired," he added. "Crime scene was littered with rounds."
Two officers were among those wounded in the shooting. One officer was shot in the leg and is currently in surgery. The second officer was shot in the arm and is undergoing care at the hospital. They are both expected to survive.
They're "doing great," Morgan told ABC News. "Expect one to be released today. The other one will be in the hospital for awhile."
"There's some real heroism today," said Capt. Timothy Kinsella, commanding officer at NAS Pensacola.
"This is a dark day for a very great place," Florida Gov. Ron DeSantis said at a press conference Friday afternoon. "It not only strikes at the heart of the community of northwest Florida but throughout the Navy."
The FBI is leading the investigation with local authorities and ATF assisting, officials said. The U.S. Attorney's Office is also involved.
According to two law enforcement officials briefed on the investigation, authorities are urgently focused on two likely possible motives: whether the shooter had religious or ideological reasons; or was there a problem or hostility that developed in the course of the training at Pensacola.
"Base security and the Naval Criminal Investigative Service are currently investigating. The names of the victims will not be released until the next of kin have been notified," the Navy said in a statement.
A handgun was identified as the weapon used by the suspect. Only security forces are allowed to carry weapons on the base, Kinsella said.
The shooter was part of an international training service where officers from partner nations are brought to NAS Pensacola to train, Kinsella said, adding that the suspect was part of the "aviation pipeline."
The base is shut down until further notice, according to Kinsella.
Mental health coordinators have been sent to talk to witnesses and the victims' families, DeSantis said. The Department of Children and Family Services has sent a mobile response team to the area.
NAS Pensacola employs more than 16,000 military and 7,400 civilian personnel, according to the base's website. The facility includes the Naval Aviation Schools Command, Naval Air Technical Training Center, Marine Aviation Training Support Group 21 and 23, the Blue Angels, and the headquarters for Naval Education Training Command.
During his roundtable on small business and red tape reduction accomplishments on Friday, President Donald Trump sent his condolences to families of the "warriors" killed and spoke about his call with the King of Saudi Arabia.
"I can tell you it's a horrible thing that took place and we're getting to the bottom on it," Trump said. "All of the investigators are there now and they're studying it very closely and terrible thing, and our condolences to the families."
....The King said that the Saudi people are greatly angered by the barbaric actions of the shooter, and that this person in no way shape or form represents the feelings of the Saudi people who love the American people. — Donald J. Trump (@realDonaldTrump) December 6, 2019
The president also echoed what he said in his previous tweet about his call with the King of Saudi Arabia.
"The king said that the Saudi people are greatly angered by the barbaric actions of the shoots and that this person in no way shape or form represents the feelings of the Saudi people who love the American people so much," Trump said.
This is the second shooting incident on a Navy base in the last week.
A 22-year-old active-duty sailor opened fire on three civilian employees, killing two, before he fatally shot himself at the Pearl Harbor Naval Shipyard near Honolulu on Wednesday, military officials said.
The suspected shooter opened fire on shipyard personnel with his M4 service rifle and then used his M9 service pistol to shoot himself, officials said.
ABC News' Eva Pilgrim, Christina Carrega, Aaron Katersky, Jack Date, Mike Levine and Elizabeth Thomas contributed to this report.