LOS ANGELES (AFP) - Police were hunting for a motive on Saturday after a gunman opened fire at Los Angeles International Airport, killing an unarmed federal official, terrifying hundreds, and sowing chaos at the busy transport hub.
Panicked travellers scrambled to escape after the shooter - identified as 23-year-old Paul Anthony Ciancia - armed with an assault rifle, blasted through a security checkpoint at the airport shortly after 9am (1600 GMT) on Friday.
Ciancia then walked calmly through the terminal seeking further victims. He was eventually stopped when police shot and wounded him.
TV footage showed people diving to the floor at the sound of gunfire and scrambling to escape the terminal.
The dead agent was the first Transportation Security Administration (TSA) employee killed in the line of duty since the group was set up following the September 11, 2001 terrorist attacks.
The lone gunman, who reportedly had a grudge against the TSA, also wounded seven people in the rampage.
But he was still carrying plenty of ammunition when he was arrested, said Los Angeles Mayor Eric Garcetti.
"There were more than 100 more rounds that could have literally killed everybody in that terminal today," he said, praising airport police. "If it were not for their actions, there could have been a lot more damage," he said.
"My prayers are with the TSA family today and with your fallen. Thank you for your courage and your service. Our country is indebted," mayor Garcetti later wrote on his Facebook account.
The mayor also ordered flags on city buildings to fly at half-mast in honour of the slain TSA agent.
While reports suggested Ciancia - who was shot several times before he went down - was a disgruntled loner, the Federal Bureau of Investigation (FBI) said it could not rule out terrorism.
The shooter opened fire in a crowded terminal of the country's third-busiest airport.
He "came into Terminal Three, pulled an assault rifle out of a bag and began to open fire", said head of the airport police Patrick Gannon.
"He proceeded up into the screening area... and continued shooting," he said.
Police chased the gunman, "engaged him in gunfire... and were able to successfully take him into custody".
The terminal remained close on Saturday as authorities carried out a detailed investigation of the shooting.
The TSA, which employs unarmed screeners at airports, confirmed that one of its employees had died. "Multiple Transportation Security Officers were shot, one fatally," said a TSA statement.
The FBI later named the shooter, and said that he was a Los Angeles resident originally from the eastern state of New Jersey.
Police found a note on the gunman voicing "disappointment in the government" but that he did not want to harm "innocent people", a law enforcement official told the Los Angeles Times newspaper.
It appeared that Ciancia was hunting for TSA agents. During the shooting spree, which lasted less than 10 minutes, he approached a number of people cowering in the terminal and pointed his gun at them, asking if they "were TSA".
If they answered "no," he moved on, the Times reported, citing witnesses who said he cursed the TSA repeatedly.
Late Friday, the TSA identified the dead officer as Gerardo Hernandez, 39, US media reported.
Before the shooting, Ciancia texted his younger brother that he might harm himself, the Washington Post reported on Saturday. This led the shooter's father to contact local New Jersey police, who in turn contacted their counterparts in Los Angeles.
LAPD officers visited Ciancia's home on Friday but could not find him, according to the Post.
Mr Brian Adamick, 43, said he saw a wounded TSA worker, with a bloodied ankle, board a shuttle bus helping passengers escape.
"It looked like it was straight out of the movies," he said.
Some 750 flights were disrupted after the Federal Aviation Administration (FAA) issued a national ground-stop.
Although there was no indication that other people were involved in the attack, the FBI said it could not rule out terrorism.
"It would be premature to comment on a motivation at this time and joint investigators have neither ruled out terrorism, nor ruled it in," said an FBI statement.
This being Los Angeles, a number of celebrities were caught up in the action.
Filming of an episode of the hit TV show Mad Men underway in nearby Terminal Four was halted, a crew member wrote on Twitter.
Actor James Franco posted a "selfie" picture of himself on a plane stopped on the tarmac by the incident.
"Some s**tbag shot up the place," he wrote in the first of a series of tweets, ending some five hours later with a more relieved message: "WE'RE OUT! - everyone was calm."
The shooting comes just weeks ahead of the stressful end-of-year travel period that includes Thanksgiving - traditionally the busiest travel time of the year - and Christmas.