A federal security agent has been killed and several other people wounded in a shooting at Los Angeles International Airport, officials say.
The Transportation Security Administration (TSA) said three of its staff had been injured, one fatally.
The suspect - named by the FBI as 23-year-old Los Angeles resident Paul Anthony Ciancia - was wounded by police and detained.
Hundreds of flights nationwide were affected by the incident.
LA Airport police chief Patrick Gannon told reporters a "lone shooter" came into Terminal 3 at 9:20 local time (16:20 GMT).
The suspect "pulled an assault rifle out of a bag and began to open fire in the terminal" inside the nation's third largest airport, he said.
He then allegedly went to a security screening area and continued shooting.
"As you can imagine, a large amount of chaos took place in this entire incident," Mr Gannon said.
It was the first time a TSA officer was killed in the line of duty, according to Los Angeles Mayor Eric Garcetti.
The TSA named the killed officer as 39-year-old Gerardo Hernandez.
Mayor Garcetti said it was fortunate that the authorities had tackled the suspect because he had been armed with more than 100 rounds of ammunition.
A law enforcement official told the Associated Press that Mr Ciancia was shot in the mouth and leg by two airport police officers.
According to US media, the alleged gunman approached potential victims asking if they worked for the TSA, and spared them if they said no.
He pushed through screening gates and walked more than 100 yards (90m) into the secure area of the terminal, Mr Gannon said, where law enforcement officers caught up with him in a food court.
As he began firing in the terminal, "everybody pancaked down on the ground", passenger Lauren Stephens, who was checking in at the time, told Reuters news agency.
Then, when more shots rang out, "I just left my bag and I just ran like hell. Everybody ran. People were falling. People were just trying to help each other out."
Another witness, Leon Saryan, told CNN that the same man he had just seen shoot a TSA officer "calmly" walked toward him and asked, "TSA?"
"I just shook my head, and he kept going," Mr Saryan said.
A number of people were reportedly injured while fleeing the scene.
Various outlets reported the suspect was carrying a note that expressed anti-government views.
Little is known about him.
Mr Ciancia's family in New Jersey told police on Friday they had received a text message from him saying he planned suicide, report US media.
"Their younger child got a text message from Paul [Ciancia] stating that there were some comments in there about his wellbeing and he wanted to possibly take his own life," a New Jersey police chief, Allen Cummings, said.
Mr Cummings said he called Los Angeles police, who sent officers to Mr Ciancia's apartment in the city.
Two roommates of Mr Ciancia told Los Angeles police on Friday they had seen him the day before and he had appeared fine, according to Mr Cummings.
A local hospital official told reporters that one of the injured was listed in a critical condition, while two other victims were in fair condition.
Some 746 flights nationwide were affected and 46 were diverted because of the incident, said airport officials.
Terminal 3 remains closed as the investigation continues.
President Barack Obama expressed concern about the shooting, but said he would leave law enforcement to talk about it.