We present a model in which households facing income and housing-price shocks use long-term mortgages to purchase houses. Interest rates on mortgages reflect the risk of default. The model accounts for observed patterns of housing consumption, mortgage borrowing, and defaults. We use the model as a laboratory to evaluate default-prevention policies. While recourse mortgages make the penalty for default harsher and thus may lower the default rate, they also lower equity and increase payments and thus may increase the default rate. Introducing loan-to-value (LTV) limits for new mortgages increases equity and thus lowers the default rate, with negligible negative effects on housing demand. The combination of recourse mortgages and LTV limits reduces the default rate while boosting housing demand. Recourse mortgages with LTV limits are also necessary to prevent large increases in the mortgage default rate after large declines in the aggregate price of housing.