The Moroccan man who French police say brandished and fired an AK-47 on a high-speed train headed to Paris from Amsterdam before he was restrained by three Americans had watched a jihadi video on his cellphone just before the attack, a prosecutor announced Tuesday.

Francois Molins formally opened a terrorism investigation, citing the actions of 26-year-old Ayoub El-Khazzani on the train Friday, as well as information from other European authorities on El-Khazzani's travels and apparent links to radical Islam.

The prosecutor told a news conference that El-Khazzani watched "a video of Islamic preaching onboard" on YouTube shortly before he got up to start walking through the train with the weapons. The suspect's phone was found in a bag left on the train.

 El-Khazzani was tackled and tied up by five passengers, including three Americans and a Briton, averting what President Francois Hollande said "could have degenerated into monstrous carnage." Another man who tried to stop him -- a French-American named Mark Moogalian -- remained hospitalized with a gunshot wound.

During questioning by authorities, El-Khazzani said he had no terrorism plans and had found a bag of weapons Thursday in a Brussels park and planned to use them to rob passengers, Molins said. But the suspect grew less and less lucid as he gave his explanation, the prosecutor added, and eventually stopped talking to investigators altogether.

More On This...

One reason investigators suspect a premeditated attack was that El-Khazzani, who claimed to be homeless and living in a Brussels park, used a first-class ticket, Molins said. The suspect refused to take an earlier train, he added, although there were seats available -- "the sign of a planned project."

El-Khazzani boarded the train Friday at a Brussels station. Besides the assault rifle, the suspect had 270 rounds of ammunition, a pistol, a box-cutter and a bottle of gasoline, Molins said.

Prosecutors also said they found a small explosive like those used in the tips of missiles hidden in the glass box containing the hammer used to break train windows in case of emergency. They did not elaborate.

With the formal investigation opened, investigating magistrates are expected to file numerous preliminary charges against El-Khazzani, including multiple counts of attempted murder in connection with terrorism, possession of weapons in connection with terrorism, and participation in a terrorist conspiracy.

The suspect had traveled through several European countries and had been repeatedly incarcerated in Spain and flagged for surveillance in France, Molins said. After five to seven months in 2014 in France, he lived in Brussels, Cologne and Vienna.

French surveillance helped authorities spot the suspect on a May 10 flight from Berlin to Istanbul, then a return flight from Antakya, Turkey, to Tirana, Albania, via Istanbul, Molins said. El-Khazzani denied going to Turkey. Authorities believe he may also have tried to go to Syria.

The train incident has highlighted growing difficulties in protecting public spaces from individual attackers.

In his speech Tuesday, the French president said the country remains "exposed" to violent extremism, and "this aggression is new proof that we should prepare ourselves for other assaults."

Hollande did not elaborate on a specific threat, although France has been on high alert for attacks all year. He stressed his commitment to counterterrorism efforts at home and abroad against extremists.

Investigators in Brussels searched two buildings in the Molenbeek-Saint-Jean neighborhood where the suspect may have stayed, the Federal Prosecutor's Office said in a statement. No one was detained, although investigators said they seized "some objects" for further examination. The statement did not elaborate.

According to French law, authorities must file preliminary charges against El-Khazzani by Tuesday night or seek a special extension to his temporary custody.

The next step will be determining where his weapons came from, how he financed them, and whether he had any accomplices, Molins said.

One of the Americans who helped thwart the attack, U.S. Airman 1st Class Spencer Stone, flew to a U.S. military base in southern Germany, where he was treated at the Landstuhl Regional Medical Center and doing well, said spokesman Chuck Roberts. Stone, who arrived Monday, seemed in good spirits, smiling and shaking hands with officials at the hospital.

Roberts said Stone is being treated for a cut to his thumb, for which a full recovery is expected with ongoing therapy, as well as a "non-critical" eye injury and other minor wounds. It's not clear when Stone will be transferred back to the U.S.

Another of the Americans, Oregon National Guardsman Alek Skarlatos is staying with Stone in Germany while he recovers. The Army announced that Skarlatos will be awarded the Soldiers Medal, the U.S. Army's highest award for acts of heroism not involving actual conflict with an enemy.

A third American who helped thwart the attack, Anthony Sadler, returned to Sacramento, California, on Tuesday evening. Sacramento's KCRA-TV showed Sadler, a Sacramento State University student, walking off a commercial plane at Sacramento International Airport, accompanied by his parents. Earlier he had flown back to the U.S. from France on a private jet made available by the CEO of Columbia Sportwear and switched to the commercial flight in Portland, Oregon.

In Georgia, the sister of Mark Moogalian described him as forthright and determined, and is not surprised by his unselfish actions on the train.

"Mark is one of the most compassionate people I've ever known," Jacqueline Moogalian-Pittman told The Associated Press. "He's a free spirit. When he sets his mind on what he wants to do, he just does it -- which is one of the reasons I wasn't surprised when I heard he went after the actual gunman."

The Associated Press contributed to this report.