Deductions & credits

If the appraisal will support the issuance of a $300K mortgage but you sell the house for $250K then the $250K is your starting point for calculating gain or loss.  The mortgage the buyer obtains is irrelevant.