Near the scene of a bombing in Chelsea that injured 29 people. Investigators want to know who caused the blast and whether a second device found was a bomb. View Full Caption DNAinfo/Ben Fractenberg

MANHATTAN — Leave the bomb, take the bag.

In two separate cases, thieves snatching bags from a city street and a train station inadvertently helped law enforcement get the upper hand in a bomb spree that injured dozens of people and spans both sides of the Hudson River, sources said.

UPDATE: CAUGHT: Chelsea Bombing Suspect Taken Into Custody

The day Ahmad Khan Rahami allegedly planted two bombs in Chelsea — one of which detonated on West 23rd Street — two thieves accidentally helped to disable his second pressure cooker bomb left inside a rolling suitcase on West 27th Street, sources said.

Read more about the Chelsea bombing:

► What We Know — And Don't Know — About the Chelsea Bombing

► Pizza Orders — And Gripes — Keep Coming for Domino's Across From Blast Site

The young men, who sources described as being well-dressed, opened the bag and took the bomb out, sources said, before placing the explosive into a garbage bag and walking away with the rolling suitcase.

"Once they picked up the bag, they seemed incredulous. They had actually picked this up off the street and they walked off with it," according to Robert Boyce, the NYPD's Chief of Detectives, who was responding to a question about DNAinfo New York's story.

"They look like they were two gentlemen just strolling up and down Seventh Avenue at the time," Boyce added.

Investigators believe they inadvertently disabled the explosive, sources said.

"It’s difficult to say right now if they at all, inadvertently perhaps even, pulled a wire," Boyce said.

Since the bomb remained intact, it allowed investigators to examine the cellphone attached to the bomb and discover that it was connected to the family of Rahami.

From there, they were able to identify pictures on social media of Rahami's family and of him, and they matched one of his photos to surveillance footage captured in Manhattan.

They also found a website where Rahami allegedly posted jihadist missives, sources said.

Rahami, who was born in Afghanistan but lived in Elizabeth, New Jersey, had deposited the second bomb about four blocks away from the one that detonated and wounded 29 people on West 23rd Street, police said.

"Who in this world finds a pressure cooker with a phone and just takes the bag?" a law enforcement source said.

The two men are not believed to be involved in the terror plot, but investigators still want to speak to them.

"We’re considering them witnesses right now. ... We’ll put their images out and hopefully get them identified," Boyce said.

Then, on Sunday night, two homeless men snatched a backpack resting atop a trash can near a train station in Elizabeth, officials said.

“They probably thought there was something of value in that backpack,” said the mayor of Elizabeth, Christian Bollwage.

They started rooting through the bag and found five explosives that officials say are tied to Rahami, prompting them to immediately drop the bag in the middle of the street and alert police, officials said.

"When they opened it up and found the wire and the pipe they immediately walked around the other corner to Elizabeth police headquarters and turned it in," Bollwage said.

“People go through life on the edge in a very difficult position yet they probably saved hundreds of lives,” the mayor added.

Investigators believe Rahami left the bomb in the Elizabeth train station "probably to get rid of the evidence" because it lacked any detonators like those used for the Chelsea devices, according to Bollwage.

"That bomb package, we speculate, was being thrown away as opposed to being set for further harm," Bollwage said.

Investigators believe Rahami also planted a bomb in Seaside Park, N.J., which exploded without injuring anyone Saturday, according to the New Jersey State Police.