Updated

Two Boston firefighters were killed Wednesday in a fire that ripped through a brownstone in a densely-populated neighborhood.

The fire started shortly before 3 p.m. in the four-story building in the city's Back Bay area. Smoke and flames fanned by strong winds poured from the roof and windows for hours.

Thirteen other firefighters were injured in the blaze, and several police officers also were taken to hospitals. Some residents had to be rescued from the upper floors of the four-story apartment building, but none was hurt, city officials said.

"Today's a sad day for the city of Boston," Mayor Marty Walsh said. "We lost two heroes here today."

The firefighters were identified as Lt. Edward J. Walsh, a 43-year-old father of three who had almost a decade of experience, and firefighter Michael R. Kennedy, a 33-year-old Marine Corps combat veteran who had been a firefighter for more than six years.

Deputy Fire Chief Joseph Finn said the fire appeared to have started in the basement but moved quickly through the building. The cause wasn't known, but he said all indications are that it was accidental and that it was the wind that caused the fire to spread through the building so quickly. Firewalls stopped the fire from consuming adjacent buildings.

"In 30 years I've never seen a fire travel that fast, escalate that quickly and create such havoc in such a short period of time," Finn said.

The Boston Police Patrolman's Association tweeted condolences to the Boston Fire Department early Wednesday evening.

Despite 30 mph winds that gusted to 45 mph and cold temperatures, people gathered to watch firefighters work from outside the building, which was still burning Wednesday night.

"The smoke was unbelievable," said Kayla Dasilva, who lives a few blocks away and went with her roommate to see what was happening.

Anna Kosmidou, who lives in the apartment building next to the one that caught fire, said she and other residents were told they could not stay there Wednesday night.

"I'm very, very afraid. I'm still in shock," she said. "They called me at work, and then I ran over here."

The last Boston firefighter killed on duty died in 2009, when the fire truck in which he was riding struck a building after its brakes failed. Two firefighters died in 2007 battling a restaurant fire in the West Roxbury neighborhood.

At Engine 33/Ladder 15, Kennedy and Walsh's station, not far from the fire and in the shadow of the Prudential Center, people stopped by to pay their respects.

Ralph Watson, a middle school principal in Cambridge, left a bouquet of roses outside the station.

"We live just down from where the fire was. It's very sad," he said. "We were standing when they took, I think, one of them by in a stretcher."

The Associated Press contributed to this report.