The mortgagee has a lien on the property (a claim). When liens are recorded they take precedence by the order they are recorded: the first lien is recorded first, the second lien second, and so on.
The only exception to this ordering is that government liens override mortgage liens, always. Also, some HOA liens are created by documents that pre-date the mortgage loan, but the CCRs of the HOA usually grant a subordination of their lien(s) to a mortgagee's.
A foreclosure, as mentioned, will wipe out the claim on the property and all subordinate liens. So, a second lien foreclosure wipes out the mechanic's lien for fixing the air conditioner, as well as the lawn guy's and the plumber's. A foreclosure of the first lien, then, wipes out the second mortgagee's claim on the property.
But, if you read your Note carefully, while the collateral is gone, the mortgagee usually retains a personal promise from you to pay him back. If he "forgives" that balance owing, then you have phantom income, which the IRS could tax.
Federal law did create a forgiveness of any tax due in the case where phantom income for a forgiveness of mortgage indebtedness occurred, but that law expired at the end of 2012. I don't know if they renewed that. The second mortgagee (or even the first) could make a 1099 report of other income to the IRS for the balance forgiven and put you on the hook.
Are they required to forgive the balance? No. If you reach agreement with them during a short sale, then they are agreeing to forgive it. They might not pursue you for the balance if the amount is small and you apparently have to way to pay it, but that is not a guarantee. Your attorney can give you better advice of what you're looking at.
Hope this helps.
Don Groff | REALTORÂ® & Mortgage Broker
Austin Real Estate Pros & 360 Lending Group
o 512.669.5599 | m 512.633.4157 | firstname.lastname@example.org
websites: http://www.AustinListed.com | http://www.360LendingGroup.com
Check with an attorney for the law in your state and how it applies to your personal circumstances.