The FBI and NYPD say they have the man responsible for terrorizing New York and New Jersey by setting off bombs this past weekend. But it took a gun battle to bring him in. It's been a remarkably fast-moving investigation and NY1 Criminal Justice Reporter Dean Meminger has the details.

A wild scene in Linden, NJ as police got into a shootout with Ahmad Khan Rahami, the suspect in the bomb blast that shook Manhattan Saturday night.

Rahami is charged with five counts of attempted murder after the exchange of gunfire with police.

"The officer just said show me your his hands and the suspect pulled out a handgun and fired," said Linden PD Captain James Sarnicki.

Linden police fired back, hitting Rahimi several times.

"The suspect shot at a police car, the bullet went through the windshield and there was a glancing off the officer's facial head area."

Police in Linden were called Monday morning because of a man sleeping in a bar doorway. When cops tried to wake him, they discovered it was the 28-year-old Rahami —the  person wanted by the NYPD and FBI for the 23rd street explosion, a pressure cooker bomb on 27th Street that didn't go off, and a bombing on the Jersey shore near a 5K military race.

"Based on the information we have now, we have every reason to believe this was an act of terror," said Mayor Bill de Blasio.

Rahami, a naturalized U.S. citizen who was born in Afghanistan, was living in Elizabeth, NJ. That's where homeless men found a bag with pipe bombs in Sunday. One bomb exploded as it was handled by a police robot.

Rahami's arrest occurred nearly 12 hours after the FBI and NYPD pulled over a car in Brooklyn with his relatives inside.

"That vehicle had been observed by JTTF personnel at a location associated with Rahami," said FBI Assistant Director William Sweeney Jr.

They were questioned and released. Officials said they were looking for no other suspects.  

"I have no indication that a cell is operating in the city or the area," Sweeney Jr. said.

But this investigation is not over. The FBI and NYPD say they're going to dig for more information.

"That's what we do," said NYPD Commissioner James O'Neill. "We are going to talk to family and talk to friends and see what the connections are."

Police say clues from all of the scenes including the pressure cooker bomb, which had a cell phone connected to it, led to Rahami.

Cops are also searching for two men who took the pressure cooker bomb out of a suitcase, and took the suitcase while leaving the bomb on the street, apparently not knowing it was a potentially deadly device.

"They look like they were just two just strolling up and down 7th Avenue at the time," said NYPD Chief of Detectives Robert Boyce. "We have no information that would link them to this at all."

But investigators want to know if those men saw anything.