On Twitter, President-elect Donald J. Trump said that he was “monitoring the terrible situation in Florida” and that he had spoken to Gov. Rick Scott.

Hours after the attack, a picture began to emerge of Mr. Santiago as a man who had served his country, but who had experienced trouble and failure. Mr. Santiago was discharged in August from the Alaska Army National Guard for “unsatisfactory performance,” according to Lt. Col. Candis A. Olmstead, the spokeswoman for the Alaska Guard. In September, Mr. Santiago became a father when his son was born, according to an aunt, Maria Luisa Ruiz, a resident of Union City, N.J., who spoke on Friday to the newspaper The Record.

In an email, Ms. Olmstead said that Mr. Santiago joined the Puerto Rico National Guard in December 2007. In 2010, he deployed to Balad, Iraq, with the 130th Engineer Battalion, which spent a year clearing roads of improvised explosives and maintaining bridges; he was awarded a Meritorious Unit Commendation.

At least two soldiers from his company were killed in insurgent attacks during the tour, but there is nothing in the record that indicates Mr. Santiago had been in combat.

Ms. Olmstead said he served in the Army Reserves before joining the Alaska Army National Guard in November 2014. Before his discharge last year, he worked as a combat engineer as a private first class. An official service record released on Friday by the Army showed that Mr. Santiago had received a number of commendations, including the Army Good Conduct Medal.

Mr. Santiago’s brother, Bryan Santiago, told The Associated Press that Esteban was born in New Jersey and moved to Puerto Rico when he was 2.

An Unknown Motive

Nelson Cruz, a Puerto Rico senator who represents Peñuelas, the city in Puerto Rico where Mr. Santiago grew up, said he met Mr. Santiago about seven or eight years ago, and found him to be a “good young man” who loved his family.

Mr. Cruz said he spoke on Friday with Bryan Santiago, who relayed that the family was shocked by the news of the killings. The family offered no known motive for the crime, but noted that Esteban had recently been hallucinating and was receiving psychological treatment.

“Bryan said his brother went to Iraq or Afghanistan, one of those places, and came back with psychological problems,” Mr. Cruz said. “He would suddenly see visions, but that he was a calm young man and was never violent.”

Esteban Santiago liked sports (particularly boxing, as Bryan is a boxing trainer) and was proud of his military career. “We don’t know what happened with this guy,” Mr. Cruz said. “He was an intelligent, brilliant young man who came back affected. When he came back from the conflict, he did not return well.”

He added that the family wanted to express condolences, but was in a state of panic over the number of news reporters outside their house.

At a news conference late Friday in Florida, officials warned that learning the gunman’s motive would be a long, complex process. “We have not ruled out terrorism, and we will pursue every angle to try to determine the motive behind this attack,” said George Piro, the special agent in charge of the F.B.I.’s Miami division.

The shooting comes at a tense time for a nation that has been watching nervously as terrorist attacks have occurred elsewhere in the world, and as Mr. Trump, who has promised to bar Muslims from entering the country, prepares to ascend to the presidency.

Image Esteban Santiago, 26, made disturbing remarks at the F.B.I. office in Anchorage in November, according to a senior law enforcement official. Credit... Broward Sheriff's Office

Officials said that he had flown on a flight from Alaska to Minneapolis, and then to Fort Lauderdale-Hollywood International Airport.

In a Facebook post, a Broward County commissioner, Chip LaMarca, said the assailant had been a passenger on a Canadian flight who had checked his weapon in his luggage and then, upon disembarking, went to the airport bathroom to load it.

“Came out shooting people in baggage claim,” Mr. LaMarca wrote.

On CNN, Mark Lea, a witness, said the gunman “just randomly shot people, no rhyme or reason.” After the shootings, the gunman lay facedown, spread eagle and “waited for the deputies to come get him,” he said.

At that point, the gunman showed no remorse, Mr. Lea said.

“He didn’t say anything,” he said. “Nothing. No emotion, no nothing. About as straight-faced as you could get.”

Witnesses also recounted scenes of confusion and fear.

“All of a sudden there was a stampede,” said Tara Webber, 41, of Allentown, Pa., who was heading home after a four-day cruise to the Bahamas and was waiting with relatives in Terminal 3 for her flight. Those who were not running, she said, “hit the floor.”

She and her father, Dan Trinkle, 63, dived under a set of plastic chairs. Ms. Webber said she almost landed on a little girl, who was crying, and tried to comfort her.

“This was the scariest thing I’ve ever done in my life,” said Ms. Webber, who works for her father’s limousine company. “We’re going to get a car and drive all the way home.”

Her father said he went for the floor like everyone else. “Then the cops told us to leave all our stuff and get out,” he said. “Everything was thrown around all over the place.”

Mr. Trickle said the police and airport authorities seemed unsure of how to handle the situation. “As far as I’m concerned, they weren’t prepared for something like this,” he said. “We were all out on the runway for hours. It made no sense.”

He said he and his family were allowed to leave after three hours and go to a hospital only because his girlfriend, Barbara Keinert, 57, had left her insulin on the cruise ship and needed another dose.

‘He Is a Lone Shooter’

The suspect’s name was made public by Senator Bill Nelson, Democrat of Florida, soon after the shooting. Mr. Nelson said he had learned the name from the administrator of the Transportation Security Administration, Peter V. Neffenger. Mr. Nelson said Mr. Neffenger had also told him the suspect was in possession of an American military identification.

Barbara Sharief, the mayor of Broward County, said authorities were confident that the gunman had acted alone.

“Based on the preliminary reviewing of the footage tapes, he is a lone shooter,” Ms. Sharief said. “He is alive, he was not harmed, not shot.”