An aviation student from Saudi Arabia opened fire in a classroom at the Naval Air Station Pensacola on Friday morning, killing three people in an attack the Saudi government quickly condemned and that U.S. officials were investigating for possible links to terrorism.

The assault, which ended when a sheriff's deputy killed the attacker, was the second fatal shooting at a U.S. Navy base this week and prompted a massive law enforcement response and base lockdown.

Twelve people were hurt in the attack, including the two sheriff's deputies who were the first to respond, Escambia County Sheriff David Morgan said. One of the deputies was shot in the arm and the other in the knee, and both were expected to recover, he said.

The shooter was a member of the Saudi military who was in aviation training at the base, Florida Gov. Ron DeSantis said at a news conference. DeSantis spokesman Helen Ferre later said the governor learned about the shooter's identity from briefings with FBI and military officials.

A U.S. official who spoke to The Associated Press on condition of anonymity identified the shooter as Mohammed Saeed Alshamrani. The official wasn't authorized to discuss the matter publicly. The official also said the FBI is examining social media posts and investigating whether he acted alone or was connected to any broader group.

During a news conference Friday night, the FBI declined to release the shooter's identity and wouldn't comment on his possible motivations.

"There are many reports circulating, but the FBI deals only in facts," said Rachel L. Rojas, the FBI's special agent in charge of the Jacksonville Field Office. "This is still very much an active and ongoing investigation."

Earlier Friday, two U.S. officials identified the student as a second lieutenant in the Saudi Air Force, and said authorities were investigating whether the attack was terrorism-related. They spoke on condition of anonymity to disclose information that had not yet been made public.

President Donald Trump declined to say whether the shooting was terrorism-related. Trump tweeted his condolences to the families of the victims and noted that he had received a phone call from Saudi King Salman.

He said the king told him 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."

The Saudi government offered condolences to the victims and their families and said it would provide "full support" to U.S. authorities investigating the shooting.

"The Ministry of Foreign Affairs affirms that the perpetrator of this horrific attack does not represent the Saudi people whatsoever," the government said in a statement. "The American people are held in the highest regard by the Saudi people."

Vice Minister of Defense Khalid bin Salman noted on Twitter that he and many Saudi military personnel have trained on U.S. military bases and gone on to fight `'against terrorism and other threats" alongside American forces. "Today's tragic event is strongly condemned by everyone in Saudi Arabia," he said.

DeSantis said Saudi Arabia needed to be held to account for the attack.

"Obviously, the government ... needs to make things better for these victims," he said. "I think they're going to owe a debt here, given that this was one of their individuals."

A national security expert from the Heritage Foundation warned against making an immediate link to terrorism.

"If there is some connection to terrorism, well, then, that's that," Charles "Cully" Stimson said. "But let's not assume that because he was a Saudi national in their air force and he murdered our people, that he is a terrorist."

Stimson said it was also possible that the shooter was "a disgruntled evil individual who was mad because he wasn't going to get his pilot wings, or he wasn't getting the qualification ratings that he wanted, or he had a beef with somebody, or there was a girlfriend involved who slighted him."

Florida U.S. Sen. Rick Scott issued a scathing statement calling the shooting an act of terrorism "whether this individual was motivated by radical Islam or was simply mentally unstable."

Scott added that it was "clear that we need to take steps to ensure that any and all foreign nationals are scrutinized and vetted extensively before being embedded with our American men and women in uniform."

U.S. Defense Secretary Mark Esper said in a statement Friday that he was "considering several steps to ensure the security of our military installations and the safety of our service members and their families." He did not elaborate.

The U.S. has long had a robust training program for Saudis, providing assistance in the U.S. and in the kingdom. The shooting, however, shined a spotlight on the two countries' sometimes rocky relationship.

The kingdom is still trying to recover from the killing last year of Washington Post columnist Jamal Khashoggi at the Saudi Consulate in Istanbul. Saudi intelligence officials and a forensic doctor killed and dismembered Khashoggi on Oct. 2, 2018, just as his fiancee waited outside the diplomatic mission.

One of the Navy's most historic and storied bases, Naval Air Station Pensacola sprawls along the waterfront southwest of the city's downtown and dominates the economy of the surrounding area.

Part of the base resembles a college campus, with buildings where 60,000 members of the Navy, Marines, Air Force and Coast Guard train each year in multiple fields of aviation. A couple hundred students from countries outside the U.S. are also enrolled in training, said Base commander Capt. Tim Kinsella.

The base is also home to the Blue Angels flight demonstration team, and includes the National Naval Aviation Museum, a popular regional tourist attraction.

Lucy Samford, 31, said her husband, a Navy reservist and civilian worker on the base, was about 500 yards (0.46 kilometers) from where the shooting happened. She said she got a call from him a little after 7 a.m. and "one of the first things out of his mouth was, 'I love you. Tell the kids I love them. I just want you to know there's an active shooter on base.'"

Her husband, whom she declined to identify, later told her he was OK.

All of the shooting took place in one classroom and the shooter used a handgun, authorities said. Weapons are not allowed on the base, which Kinsella said would remain closed until further notice.

The shooting is the second at a U.S. naval base this week. A sailor whose submarine was docked at Pearl Harbor, Hawaii, opened fire on three civilian employees Wednesday, killing two before taking his own life.