Times Square
Times SquareiStock

The teenager accused of attacking three policemen with a machete on New Year's Eve near Times Square and charged with attempted murder was linked to Islamist extremism, a senior New York City Police Department official said on Tuesday, according to Reuters.

"He knew what he was doing. He knew why he was doing it and he thought he would die in the attack," Thomas Galati, the department's chief of intelligence and counterterrorism, was quoted as having told ABC News in an interview. "He did yell out 'Allahu Akbar.'"

"He is not representing, you know, the Islamic religion but rather, you know, a very, very small percentage of people that get radicalized," Galati added.

The suspect, 19-year-old Trevor Bickford, faces charges of attempted murder of a police officer.

Police are recommending that Bickford be charged with two counts of attempted murder of a police officer and two counts of attempted assault in the attack, the New York Police Department said.

His formal arrest on Monday came two days after Bickford allegedly attacked police officers at a security screening area outside Times Square, the center of the city’s famed New Year’s Eve celebrations.

Just after 10:00 p.m. he went to the Times Square checkpoint at West 52nd Street and 8th Avenue where officers check bags for weapons or suspicious items, NYPD Police Commissioner Keechant Sewell and police said.

At the security area, Bickford allegedly pulled out a machete, struck one officer with the blade and another officer in the head with the handle, and then swung the blade at a third officer, who shot Bickford in the shoulder, according to the sources and the NYPD. The officers have been treated and released.

Bickford had been in custody and under police guard at Bellevue Hospital since the incident, according to CNN.

Earlier on Monday, the New York Post reported that Bickford, a radicalized Islamist, wrote a threatening manifesto that ordered his family to “repent to Allah and accept Islam.”

Before the attack, Bickford wrote a farewell letter to his mother in a diary, according to a New York Times report.

"I fear greatly you will not repent to Allah and therefore I hold hope in my heart that a piece of you believes so that you may be taken out of the hellfire," the Times quoted Bickford as writing.

Since 2013, American prosecutors have charged hundreds of radicalized individuals, mostly with crimes related to support for the Islamic State (ISIS).