The typical victims of the foreclosure crisis are homeowners unable to make their mortgage payments. But another face of that crisis is that of the tenant who pays the rent and doesn’t violate the lease, but is being evicted from an apartment because the lender has foreclosed and wants to make the building attractive to prospective new owners.

In some cases, tenants are hard pressed to find new housing at a comparable rent. Last year it was estimated that 20 percent of properties facing foreclosure nationwide were rental properties.

A new Massachusetts law aimed at fending off foreclosures also has good news for tenants. Under the bill signed Aug. 7 by Gov. Deval Patrick, banks and other lenders can no longer empty a foreclosed building of its tenants in order to make it easier to sell. The new law makes it illegal for the party doing the foreclosing to issue wholesale eviction notices, or to evict tenants for any reason except lease violations or nonpayment of rent.

The law doesn’t offer tenants total protection when a foreclosure situation is looming. Building owners who are in danger of having their property foreclosed and manage to find a buyer can evict renters. But once the lender takes over, tenants who have been paying their rent and abiding by their leases can’t be evicted.

Caroline Murray of the Springfield-based Anti-Displacement Project, a community organization that deals with housing issues, said the new law will be helpful to tenants but that much remains to be done to?get to the roots of the foreclosure crisis.

“The ADP is part of the national movement called Showdown in America, a grassroots movement that is taking on the big banks that crashed our economy,” Murray said. “It’s great that states are stepping in to protect everyday people. We applaud the state for doing that, but we still need to move forward. We’ve really got to get these banks to do community reinvestment, to invest back into the neighborhoods. As you know, Springfield has one of the highest foreclosure rates in the state.”

The new law also extends from 90 to 150 days the grace period that’s supposed to give owners and lenders time to renegotiate mortgages so as to avoid foreclosure.