A deficiency judgment is an unsecured money judgment against a borrower whose mortgage foreclosure sale did not produce sufficient funds to pay the underlying promissory note, or loan, in full.  The availability of a deficiency judgment depends on whether the lender has a recourse or nonrecourse loan, which is largely a matter of state law. In some jurisdictions, the original loan(s) obtained to purchase property is/are non-recourse, but subsequent refinancing of a first mortgage and/or acquisition of a 2nd (3rd, etc.) are recourse loans.
In short, many jurisdictions hold that the loans obtained at the acquisition of a property ("purchase-money") are non-recourse, and most, if not all, subsequent loans are recourse.
States that follow the title (trust-deed) theory of mortgages typically allow non-judicial foreclosure procedures, which are fast, but do not allow deficiency judgments. States that follow the lien theory of mortgages require judiciary foreclosure procedures, but allow deficiency judgments against the debtor, although some states have narrowed the time periods to seek a deficiency judgment. 
It is important to note that there is a difference between a deficiency and a deficiency judgment. A "deficiency" is the difference between the amount owed on a loan and the total amount received/collected at the closing of a loan. A deficiency judgment is a court judgment that is a public record of the amount owed and by whom. In many states, items included in calculating the amount of a deficiency judgment include: the loan principal, accrued interest and attorney fees, less the amount the lender bid at the foreclosure sale. 
In 2014 Geoff Walsh, a staff attorney with the U.S. National Consumer Law Center, said on NPR that the United States is "seeing an uptick" in the pursuit of deficiency claims, because technological developments have enabled large debt-buying institutions and mortgage insurers to more easily pursue former borrowers, who often don't know their legal rights.