WASHINGTON — President Bush on Thursday signed a measure to provide financial relief for financially strapped homeowners facing foreclosure or in bankruptcy.

The bill gives a tax break to homeowners who have mortgage debt forgiven as part of a foreclosure or renegotiation of a loan. No taxes would be owed on the value of any debt forgiven or written off. Currently such debt forgiveness is taxable income.

While the measure is anticipated to reduce taxes of some strapped homeowners by $650 million, the cost to the government would be offset in part by limiting a tax break available on the sale of second homes.

The bill was in response to a mortgage crisis touched off this spring by a blowup in high-priced home loans for risky borrowers, throwing a pall over the economy.