A “deafening’’ explosion rocked Chelsea Saturday night, injuring 29 people, blowing out scores of windows and forcing the evacuation of at least two buildings.

The blast went off in a construction Dumpster outside the Townhouse Inn of Chelsea at 131 W. 23d St.

Mayor de Blasio called the explosion an “intentional act,” but not believed to be connected to terrorism.

But tensions only rose when, three hours after the blast, a second device was found four blocks away — a pressure cooker that an early investigation found was likely also a bomb.

Police sources described the secondary device as a cooker with wiring and a cell phone attached inside a plastic grocery bag, which had been placed inside a garbage can.

“The bomb squad believes it’s real,” a police source with knowledge of the investigation told The Post of that second device, found at 27th Street between Sixth and Seventh avenues. The cooker was safely removed from the scene by NYPD.

The Bomb Squad took the suspicious device to the NYPD gun range in The Bronx to be safely tested.

Pressure cookers were used by the Boston Marathon bombers, killing three people and injuring at least 264 others on April 15, 2013.

The strength of the W. 23rd St. blast Saturday sent the 4-by-4-by-3-foot Dumpster flying from the north side of the street to the south sidewalk, and it landed without hitting anyone or anything, police sources told The Post.

One of the injuries “may be considered serious,” de Blasio said. That victim suffered a puncture wound.

The vast majority of those injured –15 men and 14 women — suffered scrapes and abrasions from flying debris.

“Thankfully, none of these are life-threatening injuries,” said FDNY Commissioner Daniel Nigro.

The cause of the explosion was still under investigation early ­Sunday.

“We do have video, and we do see the explosion,” NYPD Commissioner James O’Neill told reporters. The blast happened on O’Neill’s first day after taking over as the city’s top cop.

O’Neill said sidewalk surveillance video leading up to the explosion was under careful review.

NYPD officers, including members of the Counterterrorism Squad, responded throughout the night, along with FBI and ATF agents and police helicopters with searchlights.

The inn and an adjoining building at 133 W. 23rd Street were evacuated.

The Dumpster was consumed in a red fireball and sent up a cloud of smoke two stories high, said Deborah Griffith, 60, who was dining at a vegetarian restaurant on the block.

“People were running, holding their ears, rubbing their ears,” she said.

“I heard this deafening boom,” said Jakar Aussin, who works at a Dunkin’ Donuts at 23rd Street and Sixth Avenue.

“My first thought was, ‘Oh God, a bomb,’ so I got down on the floor. I looked outside and it’s all ­broken glass and car alarms going off.”

Police closed off the block for several hours and ordered people already there to stay ­inside.

Hundreds of people — including neighbors trying to get to their cars or apartments — milled around outside the barricades.

“Omg that explosion knocked us out of our seats on my friends terrace in #Chelsea #NYC,’’ tweeted Kimberly Gantz.

About three hours after the blast, cops rushed to 27th Street between Sixth and Seventh avenues, where they used a robot to retrieve the pressure cooker with wires, tape and a cellphone attached to it.

Police dogs were sniffing garbage cans throughout the area.

The building at 135 W. 23rd, a residence run by the Associated Blind, is being renovated and its facade is covered with scaffolding. Construction Dumpsters line the sidewalk in front of it.

Police wearing SWAT gear and holding rifles were guarding Bellevue Hospital, where some victims were taken.

Officials said the 8:40 p.m. blast does not appear to be connected to the pipe bomb that went off in a garbage can along the route of a Marine Corps charity run in Seaside Park, NJ, during the day.

No one there was injured.

Additional reporting by Shawn ­Cohen, Leonica Valentine, Stephanie Pagones, Joe Marino and Emily Saul