Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

When investigators first asked Esteban Santiago why he allegedly gunned down people in a Florida airport, he told them his mind was being controlled by the government, a federal prosecutor said Tuesday.

But the suspect soon changed his story, Assistant U.S. Attorney Ricardo Del Toro told a judge, citing an account by an FBI agent who took part in the six hours of questioning of him. Santiago, an Iraq war veteran, instead blamed ISIS, and what he'd read on the "dark web" and internet chat rooms.

Those revelations came as Santiago, 26, was denied bail for the Jan. 6 attack at Fort Lauderdale-Hollywood International Airport, in which five people died and several more were injured. His exact motive remains unclear.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Federal authorities have said they've gone through Santiago's phone, computer and internet usage and have found no evidence of contact with terrorists or terror organizations.

Tuesday's hearing also delved into Santiago's mental health history, including a week-long stay in November at the Alaska Psychiatric Institute in Anchorage following an encounter with FBI agents in that city. Santiago, according to federal officials, told agents that the CIA was forcing him to watch ISIS videos, and complained of hearing voices.

At the hospital, he was given anti-anxiety medication and melatonin, but not any psychotropic medications, Del Toro said.

Related: Fort Lauderdale Airport Shooting Suspect Esteban Santiago Said He Heard Voices: Officials

Less than two months after his release from the hospital, authorities say, Santiago bought a one-way ticket from Anchorage to Fort Lauderdale, with a connection in Minneapolis. After landing, he retrieved a gun case from baggage claim, pulled out a Walther 9 mm handgun and started shooting.

He told investigators that he'd planned the attack, Del Toro said.

Santiago's defense lawyers questioned the FBI agent who'd participated in the interview, Michael Ferlazzo, asking if any video recordings of the Anchorage FBI encounter existed. Ferlazzo said he didn't think so.

Ferlazzo, citing records, also said that Santiago was released from the psychiatric hospital in stable condition.

Santiago remains held in the Broward County jail on murder charges.