A man has pleaded guilty to the Florida airport shooting that killed five people and wounded six, blaming his rampage on severe mental illness which a psychologist said is now under control.

Esteban Santiago, 28, pleaded guilty to 11 charges stemming from the January 2017 attack in exchange for a life prison sentence.

Santiago, from Anchorage, Alaska, admitted he opened fire with a handgun in a baggage area at Fort Lauderdale-Hollywood International Airport.

He was diagnosed as schizophrenic after his arrest but was found competent for the legal proceedings.

US District Judge Beth Bloom asked Santiago why he did what he did.

Santiago initially told the FBI after the shooting that he believed he was under some form of government mind control, before switching to unfounded claims he acted in support of the Islamic State extremist group.

“Um, I don’t know. I wasn’t really thinking about it at the moment,” he told the judge on Wednesday.

“A lot of things were going on in my mind. Messages.”

The plea deal was struck after prosecutors announced they would not seek the death penalty.

Instead, Santiago agreed to a life prison sentence plus 120 years and waived all rights to appeal.

The sentence will be officially imposed by Judge Bloom on August 17 to give victims and families a chance to give statements at a hearing.

“Today the man responsible for the horrific, devastating, and tragic attack on numerous innocent people at the Fort Lauderdale airport was held accountable for his crimes,” Miami US attorney Benjamin Greenberg said in a statement.

“Although this conviction cannot restore the lives lost or forever changed by his egregious acts of violence, it shows our unwavering and united commitment to seeking justice for the victims.”

A psychologist testified that Santiago’s mental state has shown great improvement with medication since he was first arrested after the January 6 2017 attack.

Heather Holmes said Santiago – who sported black glasses and a ponytail at Wednesday’s hearing – has been reading books in the Harry Potter series while in jail and enjoys listening to National Public Radio in the afternoons.

“Certainly this is the best I’ve ever seen him,” said Ms Holmes, who has met regularly with Santiago for more than a year.

“This is the clearest he’s ever been.”

Ms Holmes added that Santiago understands the gravity of what he did.

“He’s able to, honestly, express some remorse and shock about it,” she said.

Santiago acknowledged that he flew on a one-way ticket from Alaska to Fort Lauderdale-Hollywood International Airport with a 9mm handgun in a checked weapons box.

He loaded the gun in a toilet and came out firing, emptying two ammunition magazines before lying on the floor and surrendering to police.

Fifteen bullet casings were recovered.

Prior to the shooting, he was briefly treated at an Anchorage mental institution after showing up at the local FBI office claiming to be hearing voices, then was released with no restrictions on owning a gun, authorities have said.

Santiago, a native of New Jersey, is an Iraq war veteran with the National Guard.

He has family in Puerto Rico and a young son in Alaska, court records show.

Assistant US attorney Rick Del Toro said prosecutors had consulted closely with the families of the five people killed in the shooting and the six wounded survivors.

Mr Del Toro said each of them supported the guilty plea and life sentence rather than a protracted trial and death penalty appeals.

“Their preference is for resolution of this case through a plea,” he said.