NEW YORK — A Tunisian citizen who prosecutors say radicalized one of the men accused of plotting to derail a Toronto-to-New York passenger train tried to obtain a U.S. work visa so he could help carry out terrorist attacks in this country, law enforcement officials said Thursday.

Ahmed Abassi was arrested in New York on April 22, the same day Raed Jaser and Chiheb Esseghaier were arrested in Canada and charged with plotting to cause the derailment of a Canadian VIA passenger train. His indictment was not unsealed until Thursday. Last week, Abassi pleaded not guilty to two counts of lying on his applications for a green card and a work visa to facilitate an international act of terrorism. Each count carries up to 25 years in prison.

“Mr. Abassi says he is innocent of these charges and denies them in their entirety,” his lawyer, Sabrina Shroff, said after he made a brief appearance in federal court Thursday.

About a week before his arrest, Abassi submitted immigration paperwork “stating that he intended to remain in the United States for employment, when in fact he sought to remain in the United States to facilitate an act of international terrorism,” according to the indictment. “Ahmed Abassi had an evil purpose for seeking to remain in the United States,” the U.S. attorney in Manhattan, Preet Bharara, said.

His plan was foiled, officials say, because of an undercover FBI agent who recorded “a substantial number of hours” of conversations that Abassi had with the agent and with Esseghaier, one of the Canadian arrestees.

In those discussions, Abassi “discussed his desire to engage in terrorist acts against targets in the United States and other countries,” according to court documents. Abassi also talked about wanting to provide money and other support to terrorist organizations, including al-Qaida in Iraq, and to recruit individuals to carry out attacks, prosecutors say. Among his potential targets were water supplies.

On April 12, he allegedly discussed with the undercover agent the idea of getting a visa to remain in the United States so he could work on recruiting would-be terrorists. Three days later he was arrested at John F. Kennedy International Airport in New York after arriving from an undisclosed location.

It wasn’t Abassi’s first time in New York. According to the indictment, he spent much of March in New York, and it was there that the conversations with the undercover agent and Esseghaier were recorded. Before that, Abassi lived in Canada, where police have said the alleged train derailment plan was the first known terrorism plot in that country directed by al-Qaida.

Jaser and Esseghaier are charged with conspiracy to murder for the benefit of a terrorist group, participating in a terrorist group and conspiring to interfere with transportation facilities for the benefit of a terrorist group. Esseghaier is also charged with participating in a terrorist group. Both men have denied the accusations.

Bharara, the U.S. attorney, said that Esseghaier, who is also Tunisian, was “previously radicalized by Abassi,” and a letter submitted to the court by prosecutors said that after his arrest, Abassi “acknowledged that he may have radicalized Esseghaier.”

Court documents said that among the plots discussed by Abassi and Esseghaier was one that would have involved releasing bacteria into the air or the water supply “in order to kill up to 100,000 people.”

“But Esseghaier was dismissive of that plan,” prosecutors said. The two also discussed Esseghaier’s train derailment idea, prosecutors said. Abassi told the undercover FBI agent that “while Esseghaier’s plans were good, the time was not right,” court papers said.

Law enforcement officials said none of his plans reached the point of posing a danger to anyone.