A US 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 on Friday, killing five people and wounding eight, authorities said.

The gunman was identified as 26-year-old Esteban Santiago of Anchorage, Alaska, who served in Iraq but was demoted and discharged last year for unsatisfactory performance. His brother said he had been receiving psychological treatment recently.

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

A law enforcement official told The Associated Press news agency that Santiago had walked into the FBI office in Anchorage in November to say that the US government was controlling his mind and making him watch videos by the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) group.

Agents questioned an agitated and disjointed-sounding Santiago and then called the police, who took him for a mental health evaluation, according to the official, who was not authorised 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.

One witness said the attacker shot 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.

"The guy must have been standing over me at one point. I could smell the gunpowder," Bruce Hogan, a witness, said. Hogan said a woman next to him tried to get up and was shot in the head.

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.

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

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.

Santiago's brother, Bryan, told 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 did not 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 two. He was sent to Iraq in 2010 and spent a year there, according to Puerto Rico National Guard spokesman Major Paul Dahlen. He later joined the Alaska National Guard.

The Pentagon said Santiago had gone absent 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.

The attack 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 car park at Oklahoma City's airport, and in 2015 a machete-wielding man was shot dead after he attacked federal security officers at the New Orleans airport.