PHILADELPHIA  Christopher Hall stepped tentatively through the entranceway of City Hall Courtroom 676 and took his place among dozens of others confronting foreclosure purgatory. His hopes all but extinguished, he fully expected the morning to end with a final indignity: He would sign over the deed to his house  his grandfather’s two-story row house; the only house in which he had ever lived; the house where he had raised three children.

“This is devastating,” he said last month as he sat in the gallery awaiting his hearing. “This is my childhood home. I grew up there. My mother passed away there. My grandfather passed away there. All of my memories are there.”

A union roofer, Mr. Hall, 42, had not worked since August 2008, when the contractor that employed him as a foreman went broke and laid off more than 40 people. He had not made a mortgage payment in more than a year, and his lender, Bank of America, was threatening to auction off his house through the sheriff’s office.

In most American cities, that probably would have been the end of the story: another home turned into distressed bank inventory by the national foreclosure crisis. But in Philadelphia, under a program begun last year to try to keep people in their homes, Mr. Hall entered the courtroom with a reasonable chance of hanging on.