The suspect in the New York City subway blast Monday told investigators he detonated a crude bomb after he spotted a holiday display and did it in the name of ISIS to avenge the deaths of Muslims around the world, law enforcement officials said.

Akayed Ullah, a 27-year-old Bangladeshi immigrant, said he consumed terrorist propaganda and learned how to make the explosive device through online instructions, the officials said. He assembled it at his Brooklyn apartment, they said.

There is no evidence Ullah, an electrician, had any direct contact with the ISIS. But he said his anger over U.S. bombings in ISIS-controlled territory fueled his desire to carry out a suicide bombing, according to the officials.

He used Velcro-like fasteners and zip ties to attach the bomb — made from a pipe, a 9-volt battery, matches and Christmas tree lights — to his body, according to police. He found the pipe at a job site and bought the rest of the materials himself, he told investigators.

Related: NYC attacker wore low-tech explosive device

Mindful of ISIS threats timed to Christmas, he decided to set off the device in a crowded subway passageway near the Port Authority bus terminal because he noticed a holiday image there, the law enforcement officials said.

Ullah was taken to Bellevue Hospital with wounds and burns after the Monday morning blast, which was captured on security video and spread panic during the morning commute.

Police descended on three residences in Brooklyn that were linked to Ullah or his family — who released a statement in the evening through the Council on American-Islamic Relations.

"We are heartbroken by the violence that was targeted at our city today, and by the allegations being made against a member of our family," the statement from Ullah's family said.

"But we are also outraged by the behavior of law enforcement officials who have held children as small as 4 years old out in the cold and who held a teenager out of high school classes to interrogate him without a lawyer, without his parents.

"These are not the sorts of actions that we expect from our justice system, and we have every confidence that our justice system will find the truth behind this attack and that we will, in the end, be able to learn what occurred today."

Ullah came to the United States from Bangladesh with an immigrant visa on Feb. 21, 2011. He is a legal permanent resident with a green card.

A spokesman for the New York City Taxi and Limousine Commission said he was a licensed cab driver from March 2012 to March 2015. More recently, he was working as an electrician.

Law enforcement officials said Ullah, who had traveled abroad numerous times since moving to the U.S., didn't raise any red flags before Monday. He only had several traffic tickets on his record.

Hasan Alam, a former neighbor of Ullah in the Kensington section of Brooklyn, said he had not seen him since he moved about a year ago.

"I'm actually very shocked," he said. "Because he was a religious person and very quiet, not very outgoing."

A former neighbor in Mill Basin said the suspect lived there with an older couple and two other young men. She said she would see him leaving the house with what appeared to be camera equipment and assumed he was on his way to work.

"The family is very friendly, very nice, but he was quiet. Never talked to anyone, stayed to himself," the neighbor said.

NBC News reached a relative of the suspect by phone. He was unaware of the incident and declined to comment.