Boston mourned the deaths of two firefighters who were killed when a fire driven by strong winds whipped through a brownstone and trapped them in the basement in a neighborhood just blocks from where nine city firefighters died in a 1972 hotel collapse.

Tributes poured in Wednesday for 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.

Thirteen other firefighters were injured in the blaze in the city's Back Bay district, and several police officers also were taken to hospitals. Some residents were 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 Martin J. Walsh said. "We lost two heroes here today."

Deputy Fire Chief Joseph Finn said the 9-alarm fire, which sent smoke and flames pouring from the roof and windows of the brownstone, appeared to have started in the basement but moved quickly throughout 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," he said.

Finn said Walsh and Kennedy had gone down inside stairs into the basement, and he assumed that a front window broke out and blew the fire back at them. They called a mayday within two or three minutes of entering the building.

Kennedy was found about 30 minutes later and was pulled from the building but was pronounced dead at a hospital. Walsh's body was recovered later and was removed in what fire department spokesman Steve MacDonald described as "a very solemn ceremony," in which he was carried on a stretcher out the back of the building through a line of saluting firefighters.

Some of the other firefighters were injured when they were blown down stairs by a backdraft explosion caused by the wind, Finn said.

The fire, which began shortly before 3 p.m., was under control late Wednesday night but firefighters stayed at the site overnight to extinguish any remaining flames.

Suffolk County District Attorney Daniel F. Conley assigned a prosecutor trained to investigate fatal fires to work with fire and police, a probe he said is standard procedure when there is an unattended or unnatural death.

The DA's office said the two firefighters died a few blocks from the former Hotel Vendome, where nine Boston firefighters were killed in June 1972 when a section of the building collapsed following a fire. A memorial to those men is now located in the neighborhood.

Cardinal Seán P. O'Malley offered prayers "for God's gift of peace for all impacted by this devastating loss," and New England Patriots quarterback Tom Brady, who lives in the Back Bay, extended "deepest sympathies and condolences" to the fire department and families "of our brave and selfless firefighters who gave their lives for our protection and safety today."

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.

A makeshift memorial of flowers, candles, condolence notes and even a green Red Sox baseball cap has sprung up outside the firehouse. The U.S. flag outside the station was lowered to half-staff in mourning.

Somerville firefighter Earl Johnson placed flowers at the memorial on Thursday morning before kneeling to pray. He called Walsh and Kennedy "my brothers" and said he prayed for their families.

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."

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.

Passers-by on Thursday paused on their way to work, some adding to it.