THREE people were injured yesterday when a man set off a pipe bomb in the subway near New York’s Times Square.

He also injured himself, and all four are being treated for non-life-threatening injuries in what the mayor and police labelled an attempted terror attack.

The explosion happened in a long underground passageway at the height of the morning rush hour.

Mayor Bill de Blasio and police commissioner James P O’Neill labelled it an attempted terror attack.

“Thank God the perpetrator did not achieve his ultimate goals,” de Blasio said.

The suspect was identified as 27-year-old Akayed Ullah.

Law enforcement officials said he was inspired by Daesh but had apparently not had any direct contact with the group.

Authorities said the bomb was a low-tech explosive device.

They were investigating how it was made, and combing through surveillance footage that captured the blast on video.

A video posted on social media showed the security footage.

In it, a man walks through the crowded pedestrian tunnel and the bomb suddenly going off in a plume of white smoke. Through the smoke, the suspect is then seen sprawled on the ground as bystanders flee.

Fire officials said the suspect had burns to his hands and abdomen.

The others who were injured suffered ringing in ears and headaches.