LINDEN, N.J. (AP) - LINDEN, N.J. (AP) -- An Afghan immigrant wanted in the bombings that rocked a New York City neighborhood and a New Jersey shore town was captured Monday after being wounded in a gun battle with police that erupted when he was discovered sleeping in a bar doorway, authorities said.
Ahmad Khan Rahami, 28, appeared conscious, his upper right arm bandaged and bloodied, as he was loaded into an ambulance in Linden. Authorities said he underwent surgery for a gunshot wound to the leg.
Two officers were wounded in the shootout but were not believed to be seriously hurt, authorities said.
The arrest came just hours after police issued a bulletin and photo of Rahami, a naturalized U.S. citizen from Afghanistan who lived with his Muslim family in an apartment in Elizabeth, New Jersey, over a fried-chicken restaurant owned by his father.
"We have every reason to believe this was an act of terror," New York Mayor Bill de Blasio said after Rahami's capture.
On Saturday night, a shrapnel-packed pressure-cooker bomb similar to those used in the Boston Marathon attack exploded in New York's Chelsea section, wounding 29 people, none seriously. An unexploded pressure-cooker bomb was found blocks away.
Earlier that day, a pipe bomb blew up in Seaside Park, New Jersey, before a charity race to benefit Marines. No one was injured.
Then on Sunday night, five explosive devices were discovered in a trash can at an Elizabeth train station. Investigators have yet to publicly tie Rahami to those bombs and said they are still gathering evidence.
With Rahami's arrest, officials said they have no indication there are more bombs or suspects to find, though they cautioned that they are still working to understand Rahami's connections. His motive remains unclear, New York Police Commissioner James O'Neill said.
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.
Sweeney wouldn't detail how investigators zeroed in on Rahami as potential suspect. But they were known to be poring over surveillance video and analyzing bomb fragments and components, and found similarities in the devices that led them to believe the attacks were the work of the same person or group.
Linden Mayor Derek Armstead said the break in the case came late Monday morning, 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.
Rahami pulled a gun and shot the officer -- who was wearing a bulletproof vest -- in the torso, and more officers joined in a gun battle along the street and brought Rahami down, police Capt. James Sarnicki said.
Peter Bilinskas was standing by his desk at his Linden bowling-supply shop when he heard what sounded like gunfire and saw a man walking down the street with a gun in his hand.
As a police car pulled up at the traffic light in front of the shop, the man fired about six shots at the cruiser, then continued down the street with police following him, Bilinskas said.
The shootout came after a weekend of fear and dread in the New York area and beyond.
A man who authorities say referred to Allah wounded nine people in a stabbing rampage at a Minnesota mall Saturday before being shot to death by an off-duty police officer. Authorities are investigating it as a possible terrorist attack but have not drawn any connection between the bloodshed there and the bombings.
Five people who were pulled over Sunday night in a vehicle associated with Rahami, but they were questioned and released, Sweeney said, declining to say whether they might face any charges in future.
In releasing Rahami's photo and name as someone they wanted to question, authorities also issued a cellphone alert urging the public to call in with any information about him.
Around the time Rahami was captured, President Barack Obama was in New York on a previously scheduled visit for a meeting of the U.N. General Assembly. He called on Americans to show the world "we will never give in to fear."
Rahami lived with his family on a busy street a few miles from the Newark airport. An Associated Press reporter went to the building that houses the family's restaurant and home, but it was cordoned off.
Rahami's father, Mohammad, and two of Rahami's brothers sued the city in 2011 after it passed an ordinance requiring their restaurant, First American Fried Chicken, to close early because of complaints from neighbors that it was a late-night nuisance.
The Rahamis charged in the lawsuit that they were targeted by neighbors because they are Muslims. The lawsuit was terminated in 2012 after Mohammad Rahami pleaded guilty to blocking police from enforcing the restrictions on the restaurant.
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, that's what's so scary. It's hard when it's home," McCann said.
On Sunday, a federal law enforcement official said the Chelsea bomb contained a residue of Tannerite, an explosive often used for target practice that can be picked up in many sporting goods stores.
One of the five devices found at the Elizabeth train station exploded while a bomb squad robot tried to disarm it. No one was hurt.
Pearson reported from New York. Associated Press writers Michael Balsamo and Jennifer Peltz in New York; Dake Kang and Michael Catalini in Elizabeth; and Eric Tucker, Alicia A. Caldwell and Kevin Freking in Washington contributed to this report.