Boston was in mourning Thursday after a rare nine-alarm fire in the city’s historic Back Bay area killed two firefighters who had called for help from the basement of the blaze after a shattered window appeared to cause the fire to blow back on them, officials said.

Thirteen other firefighters were injured, most with burns, along with several police officers in fighting Wednesday’s fast-moving blaze, officials said. The exact number of firefighters still hospitalized was not immediately known, officials said.

Condolences poured in to the Boston Fire Department’s Twitter feed. The tributes of sympathy joined prominent Boston officials, including Cardinal Sean P. O’Malley, who offered prayers “for God’s gift of peace for all impacted by this devastating loss.” New England Patriots quarterback Tom Brady, who lives in the Back Bay, extended his “deepest sympathies and condolences” on Facebook to the fire department and families “of our brave and selfless firefighters who gave their lives for our protection and safety today.”

“Today’s a sad day for the city of Boston,” Mayor Martin J. Walsh said Wednesday. “We lost two heroes here today.”

The dead 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.

“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,” Deputy Fire Chief Joseph Finn told reporters at the scene on Wednesday during a televised news conference.

The cause of the fire was under investigation and District Attorney Daniel F. Conley announced that he was assigning a prosecutor trained to investigate fatal fires to work on the case, a standard procedure. The initial sign, fire officials said, was the blaze was accidental.

The fire was reported about 3 p.m. in a four-story brownstone on Beacon Street in an area famed for its rows of Victorian brownstones. Strong winds seemed to feed the flames that rapidly spread through the apartment house and caused the number of alarms to quickly escalate.

Finn told reporters that Walsh and Kennedy had gone into the basement. A front window appeared to have shattered, allowing the fire to blow back on the firefighters, who called for help via radio within minutes, he said.

Kennedy was pulled from the building and pronounced dead at a hospital. Walsh’s body was recovered later and was carried on a stretcher out the back of the building through a line of saluting firefighters, Fire Department spokesman Steve MacDonald told The Associated Press.

At Engine 33/Ladder 15, Kennedy and Walsh’s station, not far from the fire, people including Earl Johnson, a firefighter from nearby Somerville, paid their respects Thursday by leaving flowers at a makeshift memorial.

“I prayed for the firefighters and their families,” he told the AP. “I had to come down and do my part. They’re my brothers,” he said as he stood at the memorial of flowers, candles, condolence notes and even a green Red Sox baseball cap.