Esteban Santiago, 26, told investigators that he planned the attack, buying a one-way ticket to the Fort Lauderdale airport, a federal complaint said. Authorities don't know why he chose his target and have not ruled out terrorism.
Santiago was charged with an act of violence at an international airport resulting in death - which carries a maximum punishment of execution - and weapons charges.
"Today's charges represent the gravity of the situation and reflect the commitment of federal, state and local law enforcement personnel to continually protect the community and prosecute those who target our residents and visitors," U.S Attorney Wifredo Ferrer said.
Authorities said during a news conference that they had interviewed roughly 175 people, including a lengthy interrogation with the cooperative suspect, a former National Guard soldier from Alaska. Flights had resumed at the Fort Lauderdale airport after the bloodshed, though the terminal where the shooting happened remained closed.
Santiago spoke to investigators for several hours after he opened fire with a Walther 9mm semi-automatic handgun that he appears to have legally checked on a flight from Alaska. He had two magazines with him and emptied both of them, firing about 15 rounds, before he was arrested, the complaint said.
"We have not identified any triggers that would have caused this attack. We're pursuing all angles on what prompted him to carry out this horrific attack," FBI Agent George Piro said.
Update: 5 ppl dead; 8 injured were taken to an area hospital.— Broward Sheriff (@browardsheriff) January 6, 2017
Investigators are combing through social media and other information to determine Santiago's motive, and it's too early to say whether terrorism played a role, Piro said. In November, Santiago had walked into an FBI field office in Alaska saying the U.S. government was controlling his mind and forcing him to watch Islamic State group videos, authorities said.
"He was a walk-in complaint. This is something that happens at FBI offices around the country every day," FBI agent Marlin Ritzman said.
On that day, Santiago had a loaded magazine on him, but had left a gun in his vehicle, along with his newborn child, authorities said. Officers seized the weapon and local officers took him to get a mental health evaluation. His girlfriend picked up the child.
On Dec. 8, the gun was returned to Santiago. Authorities wouldn't say if it was the same gun used in the airport attack.
Santiago had not been placed on the U.S. no-fly list and appears to have acted alone, authorities said.
The attack sent panicked witnesses 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.
Mark Lea, 53, had just flown in from Minnesota with his wife for a cruise when he heard three quick cracks, like a firecracker. Then came more cracks, and "I knew it was more than just a firecracker," he said.
Making sure his wife was outside, Lea helped evacuate some older women who had fallen, he said. Then he saw the shooter.
I'm at the Ft. Lauderdale Airport. Shots have been fired. Everyone is running.— Ari Fleischer (@AriFleischer) January 6, 2017
"He was just kind of randomly shooting people," he said. "If you were in his path, you were going to get shot. He was walking and shooting."
Over the course of about 45 seconds, the shooter reloaded twice, he said. When he was out of bullets, he walked away, dropped the gun and lay face down, spread eagle on the floor, Lea said.
By that time, a deputy had arrived and grabbed the shooter. Lea put his foot on the gun to secure it.
Lea went to help the injured and a woman from Iowa asked about her husband, who she described. Lea saw a man who fit his description behind a row of chairs, motionless, shot in the head and lying in a pool of blood, he said. The man, Michael Oehme, was identified as one of the dead victims on Saturday.
Santiago had been discharged from the National Guard last year after being demoted for unsatisfactory performance. Bryan Santiago said Saturday that his brother had requested psychological help but received little assistance. Esteban Santiago said in August that he was hearing voices.
"How is it possible that the federal government knows, they hospitalize him for only four days, and then give him his weapon back?" Bryan Santiago said.
His mother declined to comment as she stood inside the screen door of the family home in Puerto Rico, wiping tears from her eyes. The only thing she said was that Esteban Santiago had been tremendously affected by seeing a bomb explode next to two of his friends when he was around 18 years old while serving in Iraq.
Santiago will make his first court appearance Monday.
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.
Despite his mental evaluation, U.S. Attorney Karen Loeffler said Santiago would have been able to legally possess a gun because he had not been judged mentally ill, which is a high standard.
Santiago arrived in Fort Lauderdale after taking off from Anchorage aboard a Delta flight Thursday night, checking only one piece of luggage - his gun.
Anderson reported from Miami. Associated Press writers Tamara Lush in Pembroke Pines, Florida; Danica Coto in San Juan, Puerto Rico, and Mark Thiessen in Anchorage, Alaska, contributed to this report.