The suspect in a shooting that killed three people and injured several others at a naval base in Pensacola, Florida, on Friday morning was a member of the Saudi Air Force who was in the U.S. for training, officials said.

Several law enforcement sources identified the gunman, who was killed in the incident, as Mohammed Saeed Alshamrani.

Lt. Col. Dave Eastburn, a Pentagon spokesman, said the suspect had been scheduled to complete a three-year U.S. Air Force Foreign Military Sales training program in August. The training, which includes English language coursework and aviation and pilot instruction, was funded by Saudi Arabia, he said.

Rachel L. Rojas, FBI special agent in charge of the Jacksonville division, said at a Friday night news conference she would not yet officially confirm the shooter’s name, or disclose a possible motive.

“We are not prepared at this hour to confirm what may have motivated the shooter to commit this horrific act today,” Rojas said. “There are many reports circulating, but the FBI deals only in facts, and this is still very much an active and ongoing investigation. As soon as we can, we will share more.”

Saudi Arabia is "going to owe a debt here given that it was one of their individuals," Florida Gov. Ron DeSantis told reporters. "The government of Saudi Arabia needs to make things better for these victims."

Download the NBC News app for breaking news and politics

Two Escambia County sheriff's deputies, who were at the scene immediately after reports of shots fired at about 6:50 a.m., were injured in an exchange of gunfire with the shooter, who had a handgun, authorities said.

Law enforcement officials identify the man in this photo to be Mohammed Alshamrani. Obtained by NBC News

One officer was shot in the arm, and the other was shot in the leg and was in surgery, Chief Deputy Chip Simmons said at a news conference. They were both expected to survive.

"I could not be prouder of the men and women of the sheriff’s office," Sheriff David Morgan said. "They ran to the fight, not from the fight."

Base commander Capt. Timothy Kinsella said those on the base demonstrated "some real heroism today." He added that the base holds active shooter drills regularly.

In addition to the two sheriff's deputies, six other people were injured, officials said.

"Walking through the crime scene was like being on the set of a movie," Morgan said.

Kinsella said foreign students from ally and "partner" nations have been coming to train at the base since at least World War II. "There have always been international students training here because it's a good place to train. It's good-quality training," he said.

Pentagon spokesman Eastburn said 5,181 foreign students from 153 countries, including 852 Saudis, are in the United States for Department of Defense security cooperation-related training.

The department vets foreign nationals who intend to participate. They're screened for drug trafficking, terrorist activity, corruption and criminal conduct, according to Pentagon policy.

President Trump spoke to the Saudi king

President Donald Trump tweeted Friday afternoon that he had heard from the Saudi monarch.

"King Salman of Saudi Arabia just called to express his sincere condolences and give his sympathies to the families and friends" of the victims, Trump wrote.

The president also told reporters about the call. "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 so much," he said.

"Our condolences go to the families and to everybody involved, including the wounded," Trump added.

Other elected officials also reacted, including Rep. Mike Rogers, R-Ala., the ranking member of the House Homeland Security Committee, who said, “While the FBI is conducting a full investigation into the shooter’s motives, it certainly bears the hallmark signs of a terror attack."

"I urge Saudi Arabia to cooperate completely with the investigation. It is vital that we fully understand the specifics of how the attacker was approved to enter the United States and attend flight training,” Rogers said.

'It's been pretty surreal'

The shooting unfolded in a two-floor classroom building at the base.

Jeff Bergosh, a facilities manager at the naval station, had just arrived at the front gates in the morning when the station was put on lockdown, trapping thousands of workers in their cars.

“It’s been pretty surreal,” Bergosh told MSNBC. “We’re just praying for all the victims.”

He said more than 10,000 workers come to Naval Air Station Pensacola every day — many entering from Navy Boulevard, which Friday morning became a mileslong parking lot when the lockdown was ordered.

“When this happened was prime-time rush hour for all the base employees,” Bergosh said. “It was chaos with the ambulances and the police vehicles screaming by with the sirens. We knew pretty quickly that this was a pretty serious event.”

The base remained closed for the rest of the day, with only essential personnel allowed to enter. Pensacola Mayor Grover C. Robinson also asked residents to avoid the area around the base as investigators swarmed the scene.

'One of the darkest days'

Naval Air Station Pensacola employs more than 16,000 military and 7,400 civilian personnel. The economy and the culture of the surrounding area are largely entwined with the base, which resembles a college campus and where 60,000 members of the Navy, Marines, Air Force and Coast Guard receive training each year.

It was the nation's first naval air station and is home to the popular Blue Angels flight demonstration squadron and the National Naval Aviation Museum, making it a popular tourist destination. It is also the headquarters of the Naval Education Training Command.

DeSantis said Friday was "one of the darkest days in the base’s history."

"Anyone who serves in the Navy knows that this is a special place" because the base serves as a training hub and many in the service pass through there, the governor said.

In 2016, the base was relatively late to enact security measures to separate the nearly 1 million tourists who visit each year from the sailors, Marines and other base employees, the Navy Times reported.

It established separate entrance gates for people who worked at the base and visitors, which are about three miles apart. Tourists also can't access military areas without passing through guard booths and roadblocks.

Friday's incident was the second shooting at a U.S. Navy facility this week. On Wednesday, a U.S. sailor fatally shot two civilian Defense Department employees and wounded a third at the Pearl Harbor Naval Shipyard in Hawaii before killing himself, according to military officials.

"Our entire Navy and Marine Corps team is struck and deeply saddened by the attacks within our own naval family," acting Secretary of the Navy Thomas B. Modly said. "These acts are crimes against all of us."