FORT LAUDERDALE — An Army veteran who complained that the government was controlling his mind drew a gun from his checked luggage on arrival at the Fort Lauderdale-Hollywood International Airport and opened fire in the baggage claim area Friday, killing five people and wounding eight, authorities said.

He was taken into custody after throwing his empty weapon down and lying spread-eagle on the ground, one witness said.

The gunman was identified by authorities as Esteban Santiago, 26, who served in Iraq with the National Guard but was demoted and discharged last year for unsatisfactory performance. His brother said he had been receiving psychological treatment recently.

A law enforcement official told the Associated Press that Santiago had walked into the FBI office in his hometown of Anchorage, Alaska, in November to say that the U.S. government was controlling his mind and making him watch Islamic State videos.

RELATED COVERAGE: What we know about Esteban Santiago, the suspect in the airport shooting

Agents questioned him and called police, who took him for a mental health evaluation, according to the official, who was not authorized to discuss the investigation and spoke on condition of anonymity.

Authorities said the motive for the attack was under investigation. Shortly after the shooting, and before details of Santiago's mental health became public, Sen. Bill Nelson, D-Fla., said that it remained to be seen whether it was terrorism or the work of "someone who is mentally deranged."

Santiago had gotten into an argument with a passenger on one leg of his trip from Alaska, which ended with a Delta Air Lines flight to Fort Lauderdale, according to a CBS News report that quoted federal law enforcement sources. But at a news conference late Friday, George Piro, special agent in charge at the FBI's Miami Field Office, said he was "unaware of an incident either on the flight or at baggage claim." Piro said it's going to take time to determine the motivation for the attack.

One witness said the attacker gunned down his victims without a word and kept shooting until his handgun ran out of ammunition.

Piro confirmed that the shooter used a semiautomatic handgun, but would not detail the type of gun or say how many rounds were fired.

Panicked travelers ran out of the terminal and spilled onto the tarmac, baggage in hand.

Others crouched behind cars or anything else they could find to shield themselves as police and paramedics rushed in to help the wounded and establish whether there were any other gunmen. The airport was shut down.

"People started kind of screaming and trying to get out of any door they could or hide under the chairs," a witness, Mark Lea, told MSNBC. "He just kind of continued coming in, just randomly shooting at people, no rhyme or reason to it."

It is legal for airline passengers to travel with guns and ammunition as long as the firearms are put in a checked bag — not a carry-on — and are unloaded and locked in a hard-sided container. Guns must be declared to the airline at check-in.

Santiago arrived in Fort Lauderdale after taking off from Anchorage aboard a Delta flight Thursday night, checking only one piece of luggage — his gun, said Jesse Davis, police chief at the Anchorage airport.

At Fort Lauderdale, "after he claimed his bag, he went into the bathroom and loaded the gun and started shooting. We don't know why," said Chip LaMarca, a Broward County commissioner who was briefed by investigators.

The bloodshed is likely to raise questions of whether aviation safety officials need to change the rules.

The attack also exposed another weak point in airport security: While travelers have to take off their shoes, put their carry-on luggage through X-ray machines and pass through metal detectors to reach the gates, many other sections of airports, such as ticket counters and baggage claim areas, are more lightly secured and more vulnerable to attack.

In 2013, a gunman with a grudge against the Transportation Security Administration shot and killed one of the agency's screeners and wounded three others during a rampage at Los Angeles International Airport.

Last November, an airline worker was shot and killed near an employee parking lot at Oklahoma City's airport, and in 2015 a machete-wielding man was shot to death after he attacked federal security officers at the New Orleans airport.

"While we have authorized doubling the number of TSA canine teams to try to prevent tragedies like this, the fact is that wherever there are crowds, such as at our airports, we remain vulnerable to these types of attacks," Nelson said.

Tampa International Airport stepped up its police presence throughout the facility shortly after news of the shooting broke, said John Tiliacos, vice president of operations for the Tampa airport. Airport police were a visible presence in the terminals, some openly carrying rifles and others with canine units.

Seven flights landed in Tampa Friday after being diverted from Fort Lauderdale, Tiliacos said. Five were flights from Central America and the Caribbean and two were domestic.

Two Fort Lauderdale-based Southwest Airlines flights scheduled to arrive in Tampa at 5:45 p.m. and 6:15 p.m. Friday were canceled.

By 6 p.m., all diverted flights had landed in Tampa, and airline employees were working to help passengers find buses to Fort Lauderdale, Tiliacos said.

Among the stranded hoping to hitch a ride was Ben Lewittes, 20, who was headed to Fort Lauderdale on a Spirit Airlines flight from LaGuardia Airport in New York City when the shooting occurred.

The flight's pilot told passengers only that they were being diverted because of a "security threat" in Fort Lauderdale, Lewittes said. The confused travelers aboard the plane didn't learn the details of the shooting until after they landed in Tampa.

Still, Lewittes hoped he could complete his trip to visit a friend in Fort Lauderdale by bus.

"I'm not scared, I'm just thankful to be alive," Lewittes said.

Tampa police spokesman Stephen Hegarty said the attack in Fort Lauderdale will not have any impact on plans for security at this weekend's events surrounding the College Football Playoff National Championship.

"We've been planning for all sorts of scenarios," he said. "We think we've got a good plan, a robust plan. It involves a very visible presence of officers throughout the downtown area and throughout the events so that people can feel safe and go out and enjoy themselves. We're aware of Fort Lauderdale, but we think we've got a good plan."

The Fort Lauderdale gunman said nothing as he "went up and down the carousels of the baggage claim, shooting through luggage to get at people that were hiding," according to Lea. The killer went through about three magazines before running out of ammunition, Lea said.

"He threw the gun down and lay spread-eagle on the ground until the officer came up to him," Lea said.

The gunman was arrested unharmed, with no shots fired by law enforcement officers, and was being questioned by the FBI, Broward County Sheriff Scott Israel said.

The conditions of the wounded were not disclosed. Israel said late Friday that at least 30 to 40 more people were taken to the hospital with various injuries suffered in the aftermath of the attack.

President Barack Obama was briefed by his Homeland Security adviser, the White House said. President-elect Donald Trump said that it is a "disgraceful situation that's happening in our country and throughout the world."

Santiago's brother, Bryan, told the AP that his brother had been receiving psychological treatment in Alaska. He didn't know what his brother was being treated for.

At the Fort Lauderdale airport, inbound flights were diverted and those waiting to take off were held on the ground, as police and paramedics rushed in.

Mark Gale, director of the Fort Lauderdale-Hollywood International Airport, said that officials are trying to get the airport back in operation by 5 a.m. Saturday, but he encouraged travelers to check with their individual airlines regarding flight schedules.

Times staff writers Dan Sullivan and Anastasia Dawson contributed to this report, which includes information from the Associated Press and South Florida Sun-Sentinel.