The two brothers accused of bombing the ­Boston Marathon and killing an MIT police officer swiftly hatched a new plan for terror as they hijacked a car. Their next target, according to New York authorities: Times Square.

Tamerlan and Dzhokhar Tsarnaev carried the tools of terror, Mayor Michael R. Bloomberg of New York said Thursday. The stolen Mercedes sport utility vehicle contained five pipe bombs and a pressure cooker similar to the devices that had killed three and injured 264 in Boston.

If not for a firefight with police in Watertown, Bloomberg said, the brothers might have followed up their devastating attack in Boston with another in New York.

“We don’t know if we would have been able to stop the terrorists, had they arrived here,” said Bloomberg, who had been briefed by the FBI. ‘‘We’re just thankful that we didn’t have to find out that answer.’’

In related developments Thursday, authorities are investigating whether an MBTA Transit Police officer wounded during the shoot-out was hit by friendly fire, State Police spokesman David ­Procopio confirmed Thursday.

Richard Donohue Jr., 33, was struck in the leg by a bullet, which authorities said remained embedded there. He was listed in serious but ­stable condition Thursday night at Mount Auburn Hospital in Cambridge.

Emmanuel Dunand/AFP/Getty Images

New York City Police Commissioner Raymond Kelly said Dzhokhar Tsarnaev had initially told investigators that he and his brother decided to go to New York to “party.” But that story changed during a later interrogation, Kelly said.

“There is nothing conclusive at this time,” said a law enforcement source, who asked not to be identified but is familiar with the investigation. “There has been no forensics done.”

Another law enforcement ­official said authorities suspected that Donohue was hurt by friendly fire because of the positioning of police at the chaotic scene in Watertown last Friday morning.

“It was the fog of war,” the official said. “There’s usually one cop and one suspect. This is unprecedented.”

A neighborhood resident, who said she saw Donohue fall as she watched from the window of her home, said in an inter­view Thursday that she was immediately concerned that Donohue and other police officers were in the line of fire of fellow officers.

“There were bullets flying all around,” said the witness, who asked not to be named. “There was concern about officers ­being in harm’s way. It was a war out there.”

The second law enforcement official said that whether Donohue was hit by friendly fire or not, officers were ­involved in a chaotic scene where they were trying to subdue a dangerous suspect.

The suspect was shooting at police, and police were trying to protect themselves and each other by firing back, officials said.

“It doesn’t change anything at the scene, friendly fire or not,” the official said. “These suspects set in motion a chain of events that required this kind of response.”

State Police investigators have recovered more than 250 shell casings as they try to ­determine the sequence, direction, and source of the gunfire during the shoot-out.

“Those streets in Watertown were the most complex crime scene in the history of the ­Massachusetts State Police,” Procopio said.

Also on Thursday, federal ­investigators resumed their search of a New Bedford landfill in connection with the bombing inquiry, said law enforce­ment officials briefed on the investigation.

The landfill is several miles from the University of Massachusetts Dartmouth, where Dzhokhar Tsarnaev was a sophomore.

In New York, Bloomberg said at a press conference that the city appears to have averted a terrorist attack.

The suspects “intended to drive to New York and detonate additional explosives in Times Square,” Bloomberg said.

The FBI notified him Wednesday that Dzhokhar Tsarnaev, 19, had outlined the plan during interrogation at Beth Israel Deaconess Medical Center, where he is recovering from multiple wounds, the mayor said.

Tamerlan Tsarnaev, 26, died of injuries suffered in the shoot-out with police.

The plan apparently fell apart when the brothers discovered that the hijacked Mercedes SUV was low on fuel and they stopped for gasoline in ­Cambridge.

The carjacking victim ­escaped and alerted police, which sparked a police pursuit, a running shoot-out, and a massive manhunt that engulfed a stunned Watertown neighborhood.

The Boston office of the FBI declined to comment on Bloomberg’s statements.

New York City Police Commissioner Raymond Kelly said Dzhokhar Tsarnaev initially had told investigators that he and his brother decided to go to New York to “party.”

That story changed, he said, in a later interrogation when Tsarnaev told investigators the brothers had decided spontaneously on bombing Times Square.

The Globe has reported that the carjacking victim told ­authorities that Tamerlan ­Tsarnaev had said: “We just killed a cop. We blew up the Marathon. And now we’re ­going to New York. Don’t ­[expletive] with us.”

The first interrogation of Dzhokhar Tsarnaev was conducted Saturday evening into Sunday morning; the second was Sunday evening into Monday morning, Kelly said.

The FBI told New York ­authorities that Tsarnaev was “more lucid” during the second interrogation.

Kelly added that Dzhokhar Tsarnaev was photographed in Times Square with friends on or before April 18, 2012, and again in November 2012. He said he did not know if those visits were related to the decision to come to New York.

“Whenever we get information, we take it seriously,” Bloomberg said.

“We are going to do whatever we can to keep everybody safe in this city,” he added.

Tsarnaev has been charged in US District Court in Boston with using a weapon of mass destruction and malicious destruc­tion of property resulting in death.

Watertown Police Chief ­Edward Deveau said Thursday that he was deeply frustrated his department, as well as hundreds of other officers, were unable to find Dzhokhar Tsarnaev even though he was less than a mile from the shooting scene.

As authorities later discovered, the wounded suspect was hiding in a boat just outside a 20-block search area.

Deveau said he recalled thinking: “ ‘I’m the police chief here in Watertown, and I’m not sure he’s gone.’ We missed him, you know, by a block, but it all worked out in the end, thank God.’’

A nearby Watertown resident echoed those thoughts.

“I was surprised they didn’t catch him sooner,” said Max Kerman, who lives on Spruce Street, a short distance from where Dzhokhar Tsarnaev abandoned the black Mercedes SUV. “The place where he was hiding is so close, about a quarter of a mile.”

As federal authorities pursue leads in the Marathon ­attack, Middlesex prosecutors are working to build a murder case against Dzhokhar Tsarnaev in the shooting death of MIT police Officer Sean Collier.

“We are actively investigating, and we do expect to bring charges,” said Stephanie ­Guyotte, a spokeswoman for Middlesex District Attorney Marian T. Ryan.

Authorities have said the Tsarnaev brothers ambushed Collier while he sat in his police cruiser in Cambridge.

MIT Police Chief John ­DiFava said the Middlesex district attorney’s office would like to speak to anyone who witnessed the shooting or was near Vassar, Main, and Ames streets between 10 and 10:30 p.m. on April 18.

“I’m not sure if we have any witnesses,” said Dan Riviello, the Cambridge police spokesman. “There was a surveillance camera at MIT that captured some information.”

Footage from that camera shows the Tsarnaev brothers approaching Collier’s cruiser from behind, Riviello said. Authorities assigned to investigate Collier’s death have not interviewed the younger Tsarnaev, he added.

On Thursday, the Somerville Police Department asked the city’s Board of Aldermen to posthumously appoint Collier as a Somerville police officer, according to a statement from Chief Thomas Pasquarello. ­Collier, a Somerville resident, had been a civilian employee of the Police Department.

Also on Thursday, reports that the alleged bombers had received state benefits prompted Governor Deval Patrick to say his office would review whether the state followed all eligibility rules in granting the aid. “I understand the public is curious,” Patrick said after the annual fish stocking at Jamaica Pond in Boston.

Earlier this week, a state health and human services spokesman said that Tamerlan Tsarnaev had so little income that he qualified for state assistance until 2012 and that both brothers received benefits through their parents when they were younger.

“There are good and bad people on and off public assistance,” Patrick said, “but it’s obviously concerning that people who have done this kind of damage to us all would have been on the public dole for some period of time.”

Noah Bierman, Shelley Murphy, and Jonathan Saltzman of the Globe staff and Globe correspondents Todd Feathers and Evan Allen contributed to this report. Brian MacQuarrie can be reached at macquarrie@­globe.com.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.

Thanks & Welcome to Globe.com

You now have unlimited access for the next two weeks.

BostonGlobe.com complimentary digital access has been provided to you, without a subscription, for free starting today and ending in 14 days. After the free trial period, your free BostonGlobe.com digital access will stop immediately unless you sign up for BostonGlobe.com digital subscription. Current print and digital subscribers are not eligible for the free trial.