The fire began at and significantly damaged a three-story brick building and adjacent lumberyard in the 600 block of Pennsylvania Ave. called Penn Lumber, fire officials said. A deli next door also was damaged.

Nearly 30 fire firetrucks and 100 firefighters were called in to battle the fire in Seton Hill and were still at the scene at 8:30 p.m.

Conditions in the building worsened rapidly once firefighters responded in the late afternoon, city fire spokesman Chief Kevin Cartwright said. The first firefighters to arrive entered the building with hoses, but "within moments" the commanding officer ordered them to evacuate. As they were doing so, the building collapsed, trapping five firefighters.

All five were rescued and suffered injuries that were not considered life-threatening. They were taken to Maryland Shock Trauma Center for evaluation but mainly had scrapes and bruises, Cartwright said.

All firefighters had been released from the hospital by Tuesday morning and were described as being in good condition, Cartwright said. All units had cleared the scene, but the cause of the fire remained under investigation, he said.

As the fire burned, smoke was visible for miles and completely filled St. Mary's Park behind the buildings as it drifted north.

A nearby resident, Josh van Horne, said he smelled the smoke and thought the fire was in his home. As he went outside to look, Horne said, he saw smoke coming from the lumberyard and a workshop next to the building. Horne and other residents said the sound of the roof collapsing could be heard for blocks.

"I was packing up to evacuate; I thought it was going to spread to my place," Horne said.

Residents were asked to avoid the area near West Franklin and Greene streets.

A 31-year-old man who was sentenced to 20 years in prison in Baltimore after he pleaded guilty to possessing 5.9 grams of marijuana won an appeal Wednesday invalidating the plea — raising the possibility that he will be released.