A mortgage or encumbrance on real estate is not an obstacle to the sale or purchase of the property, and the change of ownership does not terminate the mortgage but transfers it along with the ownership right.
If you are buying a property with an existing mortgage and nothing else is agreed upon (such as deletion due to debt repayment to the mortgage creditor), you will acquire the property with the mortgage burden, meaning the buyer will assume the position of the mortgagor. The buyer will be liable for the debt secured by the mortgage. They will be exposed to the "risk" of foreclosure proceedings or enforcement proceedings for the recovery of the secured claim (and the sale of the encumbered property at a public auction).
Therefore, it is advisable to conclude a sales contract that allows you to acquire the property free of encumbrances or a mortgage. This typically means that the seller's debt (usually to a bank) needs to be repaid before or at the time of the sale, and the mortgage needs to be deleted from the land register. This can be achieved, for example, by the seller repaying the remaining debt (mortgage loan) from their savings or by using part of the sale proceeds to pay off the debt to the bank (which then issues a release certificate or permission to delete the mortgage from the land register), with the remaining part of the sale proceeds going to the seller.
It is possible, but not common, to negotiate with the mortgage creditor to assume the loan. In this case, the buyer acquires the property with the existing mortgage, enters into an agreement with the bank to assume the loan obligation, and subsequently pays the obligations arising from the assumed loan (mortgage).
Before entering into a sale or purchase transaction involving a property with a mortgage, inquire whether the creditor's claim has been fully repaid or to what extent it hasn't. Consult with an attorney to conclude an appropriate sales contract that allows you to acquire the property free of encumbrances.