The suspect was reportedly carrying the gun in his luggage and began shooting people in the baggage claim area.
A US army veteran who said the government was controlling his mind has shot dead five people at Fort Lauderdale airport in Florida.
Authorities have identified the suspected shooter as Esteban Santiago, 26, from Anchorage, Alaska, who was detained and is being questioned by the FBI and detectives.
"We're looking at every angle, including the terrorism angle," said FBI agent George Piro.
Santiago served in Iraq with the National Guard before being demoted and discharged last year for poor performance.
Relatives said he had a history of mental health problems and had recently been getting psychological treatment.
Santiago had reportedly walked into the FBI office in Anchorage in November to say that the US government was controlling his mind and making him watch Islamic State videos.
He had been questioned by agents before police took him for a mental health evaluation, but Mr Piro said he had not seemed intent on hurting anyone.
On Friday, he arrived at Ft Lauderdale just before 1pm local time (6pm UK time) on a flight from Minnesota, police said.
Reportedly dressed in a Star Wars T-shirt, he took a 9mm semi-automatic handgun from his checked luggage and began firing at people.
Broward County commissioner Chip LaMarca said on Facebook: "He claimed his bag and took the gun from baggage and went into the bathroom to load it. Came out shooting people in baggage claim."
Ari Fleischer, a former White House press secretary, said he was at the airport and "everyone was running" when shots were fired.
Panicked travellers hid in toilet cubicles, while others ran out of the terminal and crouched behind cars.
Mark Lea told MSNBC: "People started kind of screaming and trying to get out of any door they could or hide under the chairs.
"He just kind of continued coming in, just randomly shooting at people, no rhyme or reason to it."
Bruce Hogan was at the baggage carousel when he heard four or five bangs and saw everyone drop to the ground.
"The guy must have been standing over me at one point, I could smell the gunpowder," he said.
A woman next to him attempted to get up and was shot in the head, he added.
As well as the five dead, eight others were injured.
Santiago was taken away by police after throwing his gun down and lying spread-eagle on the ground, according to a witness.
Florida governor Rick Scott told reporters the shooting was "a senseless act of evil".
Fort Lauderdale-Hollywood International Airport was closed indefinitely, but was expected to reopen sometime on Saturday morning.
Flying with guns in the US is legal as long as they are kept in a locked hard-sided container as checked baggage only, under TSA rules. Ammunition is not allowed in cabin baggage but is allowed in checked baggage.