FORT LAUDERDALE, Fla. (Reuters) - Police in Alaska took a handgun from the man accused of killing five people at Fort Lauderdale’s airport on Friday, but they returned it to him last month after a medical evaluation found he was not mentally ill, authorities said on Saturday.

Esteban Santiago, a 26-year-old Iraq war veteran, had a history of acting erratically and investigators are probing whether mental illness played a role in the latest U.S. mass shooting. According to court papers, he told agents he planned the attack and bought a one-way ticket to Florida.

Santiago was charged on Saturday in federal court and could potentially face the death penalty if convicted in the case, U.S. prosecutors said.

Marlin Ritzman, special agent in charge of the Federal Bureau of Investigation’s office in Anchorage, told a news conference Santiago walked into the office in November and said his mind was being controlled by a U.S. intelligence agency. He was turned over to local police, who took him to a medical facility for a mental evaluation.

“Santiago was having terroristic thoughts and believed he was being influenced by ISIS (the Islamic State militant group,)” Anchorage Police Chief Chris Tolley told the news conference.

A handgun police took from Santiago during the evaluation was returned to him early last month, Tolley told reporters. The police chief said it was not clear if it was the same weapon used on Friday.

Officials in Anchorage said the gun was returned because Santiago had not been adjudicated to be mentally ill.

“As far as I know, this is not somebody that would have been prohibited (from having a gun) based on the information they had,” U.S. Attorney Karen Loeffler told the news conference.

Investigators said they have not ruled out terrorism as a motive and that the suspect’s recent travel is being reviewed.

Federal prosecutors charged Santiago with carrying out violence at an airport, causing serious bodily injury, using a firearm during a crime of violence and causing death to a person through the use of a firearm, the U.S. Department of Justice said in a statement.

He will appear in court in Fort Lauderdale on Monday.

Five people were killed and six wounded in the rampage, while about three dozen were taken to local hospitals with bruises or broken bones suffered in the chaos as passengers fled the crowded baggage claim area.

‘METHODICAL’ SHOOTING

Slideshow ( 15 images )

Authorities say Santiago arrived in Ft. Lauderdale on a connecting flight from Alaska and retrieved a Walther 9mm semi-automatic handgun from his checked luggage before loading it in a bathroom and shooting indiscriminately.

According to the criminal complaint, Santiago fired the weapon 10 to 15 times, aiming it at his victims’ heads.

“He was described as walking while shooting in a methodical manner,” the complaint said.

Slideshow ( 15 images )

Witnesses said the gunman, who was wearing a blue “Star Wars” T-shirt, said nothing as he fired and surrendered to police only after running out of ammunition.

The Broward County sheriff has said it took the first deputy about 70 to 80 seconds to contact the suspect after the first shots rang out and that when the deputy confronted him, he dropped the gun and was taken into custody.

Authorities said three of the six victims who suffered gunshot wounds are in intensive care. The others are in good condition. Those killed included a volunteer firefighter in his sixties and a retiree on holiday with her husband.

Santiago served from 2007 to 2016 in the Puerto Rico National Guard and Alaska National Guard, including a deployment to Iraq from 2010 to 2011, according to the Pentagon.

A private first class and combat engineer, he received half a dozen medals before being transferred to the inactive ready reserve in August last year.

An aunt said Santiago returned from his deployment “a different person,” MSNBC reported.

Santiago’s brother Bryan, who lives in Puerto Rico, told CNN he believed authorities did not do enough to help his mentally ill sibling.

“They had him hospitalized for four days, and then they let him go. How are you going to let someone leave a psychological center after four days when he is saying that he is hearing voices?” Bryan Santiago told CNN.

The attack was the latest in a series of U.S. mass shootings, some inspired by Islamist militants, others carried out by loners or the mentally disturbed.

Last June, Florida was the scene of the deadliest shooting rampage in modern U.S. history, when a gunman apparently inspired by Islamic State killed 49 people and wounded 53 at the gay nightclub “Pulse” in Orlando.