PARIS — The main suspect in the August 2015 attack on a high-speed train in northern France was under orders from the same Islamic State terrorist cell that orchestrated the Paris attacks in November 2015, his lawyer said Thursday.

Ayoub El Khazzani, 26, a Moroccan citizen who had been granted Spanish residency, was questioned by a counter­terrorism judge in Paris for more than five hours Wednesday afternoon. The event was the first time the suspect answered questions about the case, in which authorities believe that he had planned a massive attack on a crowded train bound for Paris from Amsterdam.

Khazzani was taken into custody after having been subdued by fellow passengers aboard the Thalys train, including three young American men, two of whom were off-duty members of the U.S. armed forces. No one was killed in the attack.

Khazzani’s admission of an Islamic State connection came in a statement delivered by his lawyer to the Associated Press.

For security analysts, the revelation establishes a direct link between the August 2015 attack on the train and the November 2015 attacks in Paris, which killed 130 people in a coordinated series of assaults on cafe terraces, a concert hall and a stadium.

Abdelhamid Abaaoud, the mastermind of the Paris attacks, had given Khazzani explicit orders to attack the Thalys train, the lawyer said.

This, said Jean-Charles Brisard, director of the Paris-based Center for the Analysis of Terrorism, is a “game-changer in this case.”

“We have someone in custody for the Thalys attack who likely had prior knowledge of the November 13 attacks, because he was in contact with Abaaoud. This may lead to other information and accuracy.”

Abaaoud, 28, was killed in a police raid five days after the November attacks in the Paris suburb of St. Denis.

Khazzani’s statement also contradicts his earlier insistence in the immediate aftermath of the train attack that he was “dumbfounded” that authorities would consider him an Islamist militant. His intention, Khazzani’s lawyers said at the time, was merely to rob passengers because he was hungry.

As for the Kalashnikov assault rifle seen by passengers on the train, a lawyer who represented Khazzani at the time told French television that her client had “found it in the park which is just next to the Midi Station in Brussels, where he often sleeps with other homeless people.”

France has remained in an official “state of emergency” since the November 2015 attacks, and some 230 people have died in terrorist violence here in the past two years.

In the months since the Nice attack in July, when a local man inspired by the Islamic State plowed a truck through crowds gathered to celebrate France’s national holiday, authorities have foiled several other similar plots.

In September, French security forces­ uncovered a plan to attack Paris’s Gare de Lyon, one of Europe’s busiest train stations. In November, they uncovered another plan ostensibly targeting Paris police stations and Euro Disney, typically crowded during the holiday season.

Suspects in each of those cases were linked to the Islamic State.

“It’s not inconsistent to think that despite the larger attacks, they had in mind to target other smaller places­ and facilities,” Brisard said of ISIS operatives. “And indeed targeting the Thalys was consistent with the way they were targeting at the time.”