NEW YORK (CBSNewYork) — A suspect was ordered held on $5.2 million bail late Monday after being arrested in connection with the bombings that rocked Chelsea and Seaside Park, New Jersey on Saturday.

As CBS2’s Hazel Sanchez reported, Ahmad Khan Rahami, 28, was captured Monday after an intense manhunt ended with him being wounded in a gun battle with Linden, New Jersey, police.

Rahami was charged in Union County with five counts of attempted murder of law enforcement, as well as charges of unlawful possession of a weapon and possession of a weapon for an unlawful purpose. Federal authorities are also preparing a terrorism case against him.

His bail was set Monday by New Jersey State Superior Court Judge Regina Caulfield.

Investigators say they have “no indication” that Rahami was part of broader terror cell. He was out of surgery late Monday and his condition was stable.

https://www.instagram.com/p/BKiwSEhgZju/

The gun battle that preceded Rahami’s capture erupted right outside Michael Tedesco’s home.

“It’s surreal and it’s frightening to actually have it happen literally right on my front porch.” Tedesco said.

“I heard about 10 to 12 shots — I heard nothing but gunfire,” another man said.

Linden Mayor Derek Armstead said the break in the case came when the owner of a bar reported someone asleep in his doorway. A police officer went to investigate and recognized the man as Rahami, police and the mayor said.

Responding police tried to wake up Rahami.

“At that point, the officer realized that this might be the suspect that was being sought. He then told the person, ‘Show me your hands!’” said Linden Police Capt. James Sarnicki. “At that point, then the suspect went to the side, pulled out a handgun and fired a round at our officer, striking him in the abdomen area. Fortunately, the officer had a bulletproof vest on.”

The bar owner described what he saw.

“Right away went for his gun, and cop also took out his gun, and by that time, anything anybody could realize, like, I saw two shots – ‘Pop, pop,’” said the bar owner, Harry Bains.

WATCH: Video captures shots being fired during Rahami’s apprehension.

Another officer was grazed by a bullet on his face.

The injured officers were identified as Angel Padilla and Peter Hammer.

A Prosecutor’s office source said Padilla was the one hit in the vest, while Hammer was struck by bullet fragments.

Linden police Capt. Sarnicki said Padilla was to be released late Monday, while Hammer was to be held overnight for observation.

President Barack Obama said he spoke to the two injured officers on Monday.

“They were in good spirits, and I communicated to them how appreciative the American people were, as well as people in the region,” Obama said.

Meanwhile, CBS2’s Steve Langford spoke with one of the men who spotted the suspect in Linden. The man, Jack Mazza, said he was with a group of friends and cousins where they spotted the suspect sleeping in the bar vestibule, and he said he was the one who told his friends to alert authorities.

Mazza works at a mechanic’s shop just down the block from where the shootout took place. He said he spotted the suspect earlier in the morning sleeping on a bench, but did not give it much thought.

“He had the hoodie up over his head, and he’s like in the fetal position, and you could only like see half his face,” Mazza said.

Mazza said once his group called police, it took about 15 minutes for officers to arrive, CBS2’s Alice Gainer reported. That was when chaos ensued.

“I don’t think they were talking to him. I think they just knocked on the glass and told him, you know, to get out of the way, and then he shot them,” Mazza said. “It sounded like firecrackers. One cop took off down here toward the white car, and he ran up Elizabeth Avenue. It’s crazy. I’m glad they got him, though.”

Police returned fire, shooting Rahami and placing him under arrest.

Rahami was shot at least twice, WCBS 880’s Peter Haskell reported.

Other witnesses described what they heard and saw.

“It was like a, ‘Pow! Pow! Pow!’” said witness Tosha Hardrick.

“I was coming around the corner and you know, I seen the cops coming up here, and I just heard the gunfire,” said Rommel Johnson of Linden.

Following the incident appeared conscious, his upper right arm bandaged and bloodied, as he was loaded into an ambulance in Linden. Authorities said he suffered a gunshot wound to the leg.

Thanks to alert area residents and dedicated law enforcement officers. Now…our investigation continues. Call TIPS line w/ any information. pic.twitter.com/QamY5TkDSl — Commissioner O'Neill (@NYPDONeill) September 19, 2016

As CBS2’s Meg Baker reported, New York City Mayor Bill de Blasio and police Commissioner James O’Neill said Rahami’s capture was brought about by a join effort with the public and with multiple police agencies.

“Today, our efforts were successful thanks to the brave police officers from the Linden, New Jersey Police Department,” NYPD Commissioner James O’Neill said at a news conference Monday afternoon. “They captured this dangerous individual.”

Thanks to alert area residents and dedicated law enforcement officers. Now…our investigation continues. Call TIPS line w/ any information. pic.twitter.com/QamY5TkDSl — Commissioner O'Neill (@NYPDONeill) September 19, 2016

This case marked the first time the city has used the Office of Emergency Management’s city-wide alert system to send information about the suspect directly to residents’ smartphones.

“I think the alert system is very helpful to the Police Department and the FBI, in this and in other instances also,” O’Neill said. “It gets everybody involved. It’s that share sense of responsibility.”

O’Neill said a lot of technology was involved in Rahami’s capture, but also “great old-fashioned police work.”

“We have every reason to believe this was an act of terror,” Mayor de Blasio said, adding that New Yorkers should remain vigilant.

Officials said they had no indication there were more bombs or suspects to find, though they cautioned that they were continuing to work to understand Rahami’s connections. O’Neill said his motive remains unclear.

William Sweeney Jr., the FBI’s assistant director in New York, said there were no indications Rahami was on law enforcement’s radar at the time of the bombings.

“I have no indication that there is a cell operating in the area or in the city,” he said, adding that the investigation was ongoing. “But I have no indication that there is a cell operating here.”

Sweeney wouldn’t detail how investigators zeroed in on Rahami as someone they wanted to question, but they were known to be poring over surveillance video and examining bomb fragments and components for evidence.

The arrest came just hours Monday after the FBI, NYPD and New Jersey State Police issued bulletins and photos of Rahami, a naturalized U.S. citizen from Afghanistan with an address in Elizabeth, New Jersey.

Earlier Monday, FBI agents swarmed an apartment where Rahami lived above a fried chicken restaurant in Elizabeth that is owned by his father.

The activity at the chicken restaurant came hours after one of five devices found at the nearby Elizabeth NJ TRANSIT train station exploded while a bomb squad robot attempted to disarm it.

Rahami is believed to be connected to the devices in Elizabeth as well as an unexploded pressure cooker device found near the Chelsea explosion.

Officials say surveillance video placed Rahami at both of the city locations carrying some type of package. Sources told CBS2 that the video, along with fingerprints on parts of the device, helped authorities identify Rahami.

Flip phones were also used in both the Seaside Park and Chelsea bombings, and some common compounds were detected, CBS News Senior Investigative Producer Pat Milton told WCBS 880’s Alex Silverman.

As CBS2’s Tony Aiello reported, the chain of events all started with the ominous incident in Seaside Park on Saturday morning. A device exploded before a charity 5K race to benefit Marines and sailors.

“People come down for fun and a bomb goes off,” one person said in the wake of the incident.

The race was canceled and no one was injured. But there were many questions about who would do such a thing and why.

It was the big story of the day for about 14 hours.

And then on Saturday night, a device exploded on West 23rd and Seventh Avenue, injuring 29 people. An unexploded device was found several blocks away on West 27th Street.

CBS2 obtained exclusive surveillance video that police said showed Rahami pulling a small rolling bag carrying the bomb down 23rd Street in Chelsea.

Right away, there was speculation that the Chelsea bombing attack might have had a link with the Seaside Park incident.

New York Gov. Andrew Cuomo said as investigators gathered information they learned there were “certain commonalities among the bombs,” leading authorities to believe “that there was a common group behind the bombs.”

Through Saturday night and into Sunday, law enforcement followed leads – pulling on threads and fitting pieces of the puzzle. They examined fingerprints from the 27th Street device, license plate records, and surveillance video – and it all led investigators to Rahami, Aiello reported.

On Sunday night, FBI agents in Brooklyn stopped “a vehicle of interest” in the investigation of the Chelsea explosion, according to FBI spokeswoman Kelly Langmesser.

Sources told CBS2 that five men inside the vehicle are believed to be associates of Rahami. At least one of the men in that vehicle was Rahami’s relative, CBS2’s Janelle Burrell reported.

“There was a vehicle that came to the attention of the NYPD and it was trailed, it was stopped,” de Blasio said. “Individuals were questioned.”

The FBI stopped the vehicle because they had reason to believe that Rahami was inside, but he was not. Investigators suspect that the five men were driving from Staten Island heading to John F. Kennedy International Airport when investigators ordered them to pull over.

The men were taken in for questioning and have since been released.

Before Rahami’s capture, Cuomo said investigators have no reason to believe there are further threats, but the public should “be on constant guard.”

While authorities believe Rahami is the main suspect behind the explosions, New Jersey FBI special agent Tim Gallagher said law enforcement will leave no stone unturned, WCBS 880’s Kelly Waldron reported.

“Identify the subject and build out their network. And that’s what we’re doing right now along with our partners in federal and local law enforcement,” Gallagher said.

Around the time Rahami was taken into custody, President Barack Obama was in New York on a previously scheduled visit for a meeting of the U.N. General Assembly, and said it was “extremely fortunate” nobody was killed in the bombings.

He called on Americans to show the world “we will never give in to fear.”

“We all have a role to play as citizens to make sure we don’t succumb to that fear. And there’s no better example of that than the people of New York and New Jersey,” the president said. “Folks around here, they don’t get scared.”

Elizabeth Mayor Christian Bollwage said Rahami’s father, Mohammad Rahami, and two brothers sued the city after it passed an ordinance requiring the First American Fried Chicken restaurant to close early because of complaints from neighbors that it was a late-night nuisance. They claimed the shop hours were restricted because they were Muslim. The suit was dropped one year later.

Ryan McCann, of Elizabeth, said that he often ate at the restaurant and recently began seeing the younger Rahami working there more.

“He’s always in there. He’s a very friendly guy,” McCann said. “That’s what’s so scary. It’s hard when it’s home.”

Officials also said Rahami had traveled to Afghanistan three times recently. Friends said Rahami had changed since the visit — noticing that his personality had become more stern and he had grown a beard.

Law enforcement sources told CBS News Rahami also traveled to Pakistan during one of his trips to Afghanistan.

Rep. Albio Sires, D-N.J., told CBS News Rahami contacted his office from Pakistan in 2014 in hopes to get his pregnant wife a visa.

Investigators will now have to do a deep dive into Rahami’s mindset and motivation.

(TM and © Copyright 2016 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2016 CBS Broadcasting Inc. Used under license. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)