A Yemeni man from Brooklyn who traveled to the Middle East to join the Islamic State terror group later expressed support for a truck attack in Times Square similar to the carnage carried out in Nice, France, according to a federal complaint filed on Monday.

Mohamed Rafik Naji was charged in federal court in Brooklyn with attempting to provide material support to a foreign terrorist group for visiting Turkey and Yemen in 2015 to fight for the Islamic State and then discussing a terror attack with an informant after his return to the United States.

“If there is a truck, I mean a garbage truck and one drives it there to Times Square and crushes them shshshshshsh,” he said in a taped conversation with the informant. “Times-Square day.”

Prosecutors did not charge that Naji ever successfully joined the Islamic State or that he was on a mission in the U.S., but alleged that he spoke favorably of the idea based on what he had seen on the internet.

“They want an operation in Times Square, reconnaissance groups already put out a scene, the Islamic State already put up scenes of Times Square, you understand,” he said. “I said that was an indication for whoever is smart to know.”

Naji’s discussion of a Times Square attack came on July 19, five days after Tunisian Mohamed Lahouaiej-Bouhiel drove a truck into a Bastille Day crowd in Nice, killing 86 people. Monday’s charges triggered a statement from New York Gov. Andrew M. Cuomo.

“The arrest . . . is a sharp reminder of the evolving threat of global terrorism,” Cuomo said. “While we do not have any specific threat at this time, public safety is paramount and we will continue to work aggressively with all local and federal partners.”

advertisement | advertise on newsday

Prosecutors described Naji, 37, as a lawful permanent resident of the United States. He was arrested on Monday, and was detained after an appearance in federal court in Brooklyn. His defense attorney Monday night said Naji has a right to be presumed innocent.

The government said that Naji expressed sympathy for the Islamic State in Facebook posts and communications with the informant and “Individual 1” – a person who appeared to be his wife or girlfriend – dating back to 2014.

It said that he traveled to Istanbul in March, 2015, and shortly afterward began sending emails from an Internet Protocol address in Yemen, in which he described efforts to get into Islamic State-controlled portions of Yemen and said, “I belong to Islamic State only.”

In one email when “Individual 1” asked if she should have come, Naji allegedly responded, “It’s good and it’s bad no electricity no wifi on certain areas and u need lot money to get aroun andbecareful who u talk to bcuz u end up dead lotta spy’s.”

He returned to the U.S. in September 2015, and subsequently met multiple times with the informant, who recorded conversations about his travel to the Middle East. The conversation about a Nice-style attack in Times Square occurred in July.