FORT LAUDERDALE, Fla. -- 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 airport and opened fire in the baggage claim area Friday, killing five people and wounding eight, authorities said.

A Florida official said initially Friday that the shooter had arrived aboard a Canadian flight, but Canadian officials said that was not the case.

Canadian Embassy spokeswoman Christine Constantin said in an email to The Associated Press that the suspect did not travel from Canada and was not on an Air Canada flight. She said the suspect has no connection to Canada.

The shooting happened at the airport's terminal 2, where Air Canada and Delta operate flights.

"We understand from officials he was on a flight originating in Anchorage, transiting through Minneapolis and landing in Ft. Lauderdale," Constantin's email says.

Global Affairs Canada also said the flight on which Fort Lauderdale airport suspect arrived did not originate in Canada nor was a Canadian carrier involved. Air Canada said it has no record of any passenger with the name of suspect nor of any checked guns on any of its flights to the city.

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

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

The gunman was identified as 26-year-old Esteban Santiago of Anchorage, Alaska, 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 Anchorage in November to say that the U.S. government was controlling his mind and making him watch Islamic State videos.

Agents questioned an agitated and disjointed-sounding Santiago and then called police, who took him for a mental health evaluation, according to the official, who was not authorized to discuss the case and spoke on condition of anonymity. The official said Santiago did not appear intent on hurting anyone.

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 of Florida said that it remained to be seen whether it was terrorism or the work of "someone who is mentally deranged."

One witness said the attacker gunned down his victims without a word and kept shooting until he ran out of ammunition for his handgun, sending panicked travellers running out of the terminal and spilling onto the tarmac, baggage in hand.

Others hid in bathroom stalls or crouched behind cars or anything else they could find as police and paramedics rushed in to help the wounded and establish whether there were any other gunmen.

Bruce Hugon, who had flown in from Indianapolis for a vacation, was at the baggage carousel when he heard four or five pops and saw everyone drop down on the ground. He said a woman next to him tried to get up and was shot in the head.

"The guy must have been standing over me at one point. I could smell the gunpowder," he said. "I thought I was about to feel a piercing pain or nothing at all because I would have been dead."

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 travellers 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.

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 laid 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, Sheriff Scott Israel said.

The Broward Sheriff's Office said on social media Friday night that 37 people were injured after the shooting but didn't give details about how.

The condition of the wounded was not disclosed. At least one of the victims was seen lying in a pool of blood with what appeared to be a head wound.

The airport was shut down, with incoming flights diverted and outgoing flights held on the ground.

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" and that it was too soon to say whether it was a terrorist attack.

Santiago's brother, Bryan, told the AP that his brother had been receiving psychological treatment in Alaska. He said Santiago's girlfriend alerted the family to the situation in recent months. Bryan Santiago said that he didn't know what his brother was being treated for and that they never talked about it.

He said Esteban Santiago was born in New Jersey and moved to Puerto Rico when he was 2. He was sent to Iraq in 2010 and spent a year there with the 130th Engineer Battalion, according to Puerto Rico National Guard spokesman Maj. Paul Dahlen. He later joined the Alaska National Guard.

The Pentagon said Santiago had gone AWOL several times during his stint with the Alaska National Guard and was demoted -- from specialist to private first class -- and given a general discharge, which is lower than an honourable discharge.

John Schilcher told Fox News he came up to the baggage claim and heard the first gunshot as he picked up his bag off a carousel.

"The person next to me fell to the ground and then I started hearing other pops. And as this happened, other people started falling and you could hear it and smell it, and people on either side of me were going down and I just dropped to the ground," said Schilcher, who was there with his wife and mother-in-law. "The firing just went on and on."

"I was down on the floor. When we finally looked up there was a policeman standing over me," he said. "That's when I assumed it was safe."

Associated Press writers Freida Frisaro and Adriana Gomez-Licon in Miami; Lolita C. Baldor and Eric Tucker in Washington; Becky Bohrer in Juneau, Alaska; David Koenig in Dallas; and Danica Coto in San Juan, Puerto Rico, contributed to this report.