Residents who have been holed up in their homes, media and law enforcement officials who have been engaged in a day-long manhunt for the at-large suspect in the Boston Marathon bombing let out a cheers after it was confirmed that Dzhokhar Tsarnaev had been apprehended.

The Boston Marathon bombing suspect was captured alive but wounded Friday night — after holing up in a boat in a suburban backyard following a bloody rampage that left a cop dead and a daylong manhunt that shut down the city.

The arrest of Dzhokhar Tsarnaev, 19, and the earlier death of his brother during a firefight with cops, ended five days of terror sowed by the double bombing at the marathon finish line, which killed three people, wounded 176 and left the city of Boston on edge.

"We got him," Boston Mayor Tom Menino tweeted.

"CAPTURED!!! The hunt is over. The search is done. The terror is over. And justice has won," the Boston Police Department said on its Twitter account.

Cops cheered as the suspect was taken into custody in Watertown, Mass., just before 9 p.m. Later, the people of Watertown flooded the streets, cheering every passing police car and armored vehicle in an impromptu parade. Chants of "USA! USA!" broke out. In Boston, people danced in the streets outside Fenway Park.

Dzhokhar Tsarnaev, a suspect in the Boston Marathon bombing, has been apprehended after a day-long manhunt in a Massachusetts neighborhood. NBC's Brian Williams reports.

Police cornered Tsarnaev -- a naturalized U.S. citizen of Chechen origin -- around 7 p.m., less than an hour after police lifted a stay-indoors order for the city and its suburbs.

A resident had gone outside to smoke and noticed a tarp on the boat was flapping, a relative told NBC News. When he went to investigate, he saw what looked like a curled-up person and bloody clothes.

The man "freaked out," ran into the house and called police, the relative said.

Thermal imaging from helicopters confirmed there was a person in the boat, officials said.

Over the course of two hours, several bursts of gunfire could be heard. The police exchanged fire with Tsarnaev, threw flash-bang grenades designed to disorient him and brought a negotiator to the scene as night fell, officials said.

Just before 9 p.m., the wounded Tsarnaev was taken into custody. "He sustained significant blood loss," a law enforcement official at the scene said.

As an ambulance took the suspect to Boston Beth Israel Deaconess Hospital — where he was in serious condition — people lining the streets applauded in joy and relief.

“We are so grateful to be here right now, so grateful to able to bring justice and closure to this case,” Massachusetts State Police Col. Timothy Alben said at a briefing. “We’re exhausted, folks, but we have a victory here.”

President Barack Obama praised the outcomes but said many questions remained. Among them, he said: “Why did young men who grew up and studied here as part of our communities and our country resort to such violence?”

Who is bombing suspect Dzhokhar Tsarnaev? Former classmate Dylan Whitaker and former neighbors Susan Musinsky and "Emily" described the person they once knew to MSNBC's Lawrence O'Donnell.

Authorities are also not sure of a motive or whether the suspects had help. Even as the standoff took place in Watertown, the FBI was taking three people in for questioning in New Bedford, Mass., who were believed to be former roommates of Tsarnaev.

"No one was detained. No one was arrested," a spokesman with the Massachusetts FBI office later said, once the two men and one woman questioned in connection with Tsarnaev were released.

But the president declared: “Whatever hateful agenda drove these men to such heinous acts will not, cannot, prevail. Whatever they thought they could achieve, they’ve already failed.”

Tsarnaev will be questioned by a federal team called the High Value Detainee Interrogation Group, which includes officials of the FBI, CIA, and Defense Department, an Obama administration official said.

His apprehension capped a manhunt that had the city of Boston and its suburbs on total lockdown after the execution of a college campus patrol officer, a carjacking and the death of Tsarnaev's 26-year-old brother, Tamerlan, during a 200-bullet confrontation with cops.

The overnight violence had triggered an extraordinary shutdown of transportation, schools and businesses in Boston and its suburbs, with police warning more than a million people to hunker down behind locked doors while SWAT teams fanned out and bomb squads collected seven homemade explosive devices.

The brothers' bloody last stand began about five hours after the FBI released surveillance photos of two "extremely dangerous" men suspected of planting two bombs near the finish line of Monday's Boston Marathon, killing three and wounding 176.

Read more: Who are the brothers accused of the Boston Marathon bombing?

Police are at the Cambridge, Massachusetts, home of the Boston Marathon bombing suspects, haven't yet entered the building, suspecting it may be booby-trapped. NBC's Ron Allen reports.

Tips about the identity of the suspects were still pouring in when the Tsarnaev brothers fatally shot Massachusetts Institute of Technology officer Sean Collier, 26, in his vehicle at 10:20 p.m., law enforcement officials said.

The brothers then carjacked a Mercedes SUV, holding the driver captive for a half-hour while they tried to use his cash card to get money from three ATM's, a source said. At the first, they put in the wrong number; at the second, they took out $800 and at the third, they were told they had exceeded the withdrawal limit, the source said.

The carjacking victim was released unharmed at a gas station in Cambridge, sources said. He told police the brothers said they were the marathon bombers and had just killed a campus officer.

As the duo sped in his car toward Watertown, a police chase ensued and they tossed explosive devices out the window, officials said.

There was a long exchange of gunfire, according to Andrew Kitzenberg of Watertown, who took photos of the clash from his window and shared them via social media.

“They were also utilizing bombs, which sounded and looked like grenades, while engaging in the gunfight,” he told NBC News in an interview. “They also had what looked like a pressure-cooker bomb.

“I saw them light this bomb. They threw it towards the officers,” he said. “There was smoke that covered our entire street.”

A transit officer, identified as Richard H. Donahue, 33, was seriously injured during the pursuit. Authorities said he underwent surgery at Mount Auburn Hospital.

Kitzenberg said he saw the firefight end when Tamerlan Tsarnaev ran toward the officers and ultimately fell to the ground.

Tamerlan -- the man in the black hat from FBI photos released six hours earlier -- had an improvised explosive device strapped to his chest, law enforcement officials said.

Dzhokhar -- the brother who was wearing a white hat in the surveillance photos from the marathon -- got away when he drove the SUV through a line of police officers at the end of the street, Kitzenberg said.

Law enforcement sources told NBC News that blood found at the scene suggested Dzhokhar may have been wounded in the gun battle.

During the lockdown, subways and buses were shut down, Amtrak service to Boston was cut, and college campuses were closed. The Red Sox and Boston Bruins' home games were canceled.

Watertown was the epicenter of the search. Frightened residents were trapped inside as convoys of heavily armed officers and troops arrived by the hour and snipers perched on rooftops and in backyards.

When police finally gave residents the OK to venture outside, some cheered as they stepped outside, only to be swept back inside when shots rang out, and police converged on Tsarnaev's hideout.

An administration official said Tsarnaev was not read his Miranda rights and could be questioned without them for up to 48 hours under a special legal exception used in cases where public safety is at stake.

In a statement late Friday, The FBI said they interviewed Tamerlan in early 2011, following a tip from "a foreign government" that he was "a follower of radical Islam" and was preparing to leave the United States to join underground organizations.

The FBI said its interview two years ago of Tsarnaev and his family, along with checks of travel records, Internet activity and personal associations, "did not find any terrorism activity" at the time.

NBC News' Jonathan Dienst and Kasie Hunt contributed to this story.

Slideshow: Search for suspects in Boston Marathon bombings Dominic Chavez / EPA A tense night of police activity that left a university officer dead on campus just days after the Boston Marathon bombings and amid a hunt for two suspects caused officers to converge on a neighborhood outside Boston, where residents heard gunfire and explosions. Launch slideshow

Related:

Who are the brothers accused of the Boston Marathon bombing?

Chechen insurgents deny any link to marathon bombing

What we know: Timeline of terror hunt

‘Dedicated officer’ gunned down by Boston Marathon suspects at MIT

Slideshow: Bombings at Boston Marathon

Boston bombing spurs Senate debate on tighter immigration screening

Tweeting police chatter creates confusion over Boston suspect

Missing student's family staggered by false accusation

This story was originally published on