The Afghan immigrant who authorities believe planted bombs in New Jersey and New York this weekend was captured Monday after a dramatic gun battle with police that was sparked when officers found him sleeping in the doorway of a bar.

Officials had launched a dragnet earlier Monday in search of Ahmad Khan Rahami, the 28-year-old naturalized U.S. citizen who was identified as the primary person of interest in the Saturday night blast in New York's Chelsea neighborhood, an explosion in New Jersey's Seaside Park on Saturday morning and a foiled bomb attack Sunday night near a train station in Elizabeth, NJ.

The hunt for Rahami turned out to be brief. A bar owner in Linden, NJ spotted a man sleeping in his doorway Monday morning and called police. An officer confronted the man around 10:45 a.m., and soon recognized the person as Rahami, officials said. Rahami pulled out a gun and shot the officer, identifed by the Linden mayor's office as Angel Padilla, in the abdomen. Padilla was wearing a bulletproof vest.

A second police officer, idenitifed as Investigator Pete Hammer, had a bullet graze his head. Both officers were expected to be okay.

Rahami was shot at least once in the leg and eventually brought down and captured alive, Union County Prosecutor Grace Park said. He was taken to University Hospital in Newark where he underwent surgery, Fox News confirmed.

Rahami was charged late Monday in Union County with five counts of attempted murder of a police officer. He was being held on $5.2 million bail and remained at a hospital. It wasn't known if Rahami had an attorney, as messages left with phone numbers listed for family members by the Associated Press weren't returned. Federal charges in the bombings have yet to be filed.

Linden, the city where Rahami was captured, is about four miles from Elizabeth, where Rahami was last known to have lived. The FBI had launched a raid at his apartment, located above a fried chicken restaurant, on Monday morning. Elizabeth is also the city where investigators discovered five suspicious devices -- one of which exploded while a bomb squad robot tried to disarm it -- near a train station on Sunday night.

"Today I believe we're going to find out that [the bombing] was influenced by foreign sources," Gov. Andrew Cuomo said Monday on "Fox & Friends."

Two U.S. officials told Reuters on Monday that the bomb plot likely involved several individuals, a revelation that came hours after federal authorities on Sunday night conducted a traffic stop in Brooklyn of a “vehicle of interest” in the bombings.

Officials said Monday that the car was identified after having been at a location associated with Rahami. The individuals in the vehicle were no longer in custody, the FBI said Monday.

New York City Mayor Bill de Blasio noted during a Monday news conference that authorities weren't currently searching for any other suspects. The assistant director of the FBI's field office in New York, William Sweeney Jr., said "there is no indication that there's a cell" in the area.

Following the Chelsea explosion -- which injured 29 people -- on West 23rd Street at 8:30 p.m. on Saturday, police found a second, unexploded device four blocks away. The device was described as a pressure cooker with wires and a phone attached. The contraption, which bore a resemblance to the bomb used in the 2013 Boston Marathon attack, was placed in a plastic bag.

Officials said Rahami's fingerprint was found on the unexploded bomb discovered on West 27th Street. Authorities were still searching for two people who removed that bomb from a duffle bag after it had allegedly been placed on the street by Rahami. The pair placed the device in a plastic bag and then walked off with the duffel bag. Police said the individuals were only considered witnesses.

The Chelsea bombing came 11 hours after a pipe bomb exploded about 80 miles south in a New Jersey garbage can near the route of a charity 5K race. That explosion occurred in Seaside Park, a borough about 60 miles from Elizabeth. No one was injured in that blast. Runners were slated to be near the location of the explosion when it went off, but the race was delayed after an unattended backpack was discovered.

Authorities said the New York and New Jersey bombs used flip phones as detonators. Several media outlets also reported the New York bombs contained shrapnel consisting of ball bearings and BBs.

Local and federal officials said Rahami had not been on law enforcement's radar before the explosions, and the FBI said they had no knowledge of Rahami receiving any weapons or explosives training overseas.

Fox News' Rick Leventhal and Matt Dean and The Associated Press contributed to this report.