The principle upon which the equities of the various claimants to the surplus in this ease should be determined is that the portions of the-mortgaged premises first aliened shall be the last to be sold to pay the mortgage debt. Where the alienation, however, is not absolute, as by a deed in fee-simple, but only qualified, as by a mortgage, the effect of such alienation is to postpone the application of the property which it covers to the payment of the general mortgage debt only to the extent of the amount secured by the junior mortgage. Any surplus arising after the satisfaction of the junior mortgage is applicable upon the general mortgage, because the mortgagor is primarily liable for the debt, and any equity of redemption or any of the mortgaged lands remaining in his hands should go towards the payment of the mortgage debt in preference to premises or funds upon which his alienees have claims. The mortgage to Fay, therefore, being an alienation of the property which it covered only to the extent of Fay’s claim, any surplus remaining after the payment of that claim ought to be applied to the mortgage foreclosed in this action. When the mortgage was executed to the Brainerd Quarry Company, that corporation became entitled to have any equity in the plot which had been mortgaged to Fay applied to the satisfaction of the general mortgage in preference or prior to the plot mortgaged to the company. And upon the same principle the mortgage to the Brainerd Quarry Company only relieved the plot which it covered from prior incumbrances so far as it was necessary to discharge the lien of the company, and any surplus arising after the payment of the company’s claim became applicable to the satisfaction of the next mortgage in order of priority executed by the defendant Osborne, and so on till the fund was exhausted.
It is urged that the judgment of foreclosure in which was directed the order in which the different parcels should be sold is conclusive on this application to distribute the surplus. We think not. The pleadings raise no issue as to the rights of the subsequent lienors. The complaint did not set forth the character or relative priorities of the subsequent liens. No answer was interposed, setting up a lien of any defendant, or asking for any determination or judgment as to the rights of any defendant. The judgment, therefore, does not assume to fix those rights except so far as they are necessarily involved in determining the order of sale. In the view we have taken of the case, the sale of the whole mortgaged premises was necessary so that a proper distribution of the proceeds might be made among the various lienors. The *865only provision of the judgment relating to this subject is a direction that the eight mortgaged lots be sold in a pi escribed order. As a matter of fact, all were sold under the decree. We do not think this mere direction as to the order of sale should be deemed a conclusive adjudication as to the rights of the junior incumbrancers, each of whom was obliged in the surplus money proceedings to establish his lien. The decree, of itself, would not give any one of them a right to share in the surplus. The respective priorities of their several liens could hardly have been fixed when the existence of the liens themselves was left open for determination. Our conclusion is that the order of the special term, so far as it awards the payment of the Fay mortgage, should be affirmed. The other directions of the order should be reversed, and the surplus directed to be distributed among the holders of the various junior mortgages according to the dates when they respectively became liens; except that in no case should a greater amount be paid on account of the liens on any one lot than was realized for that lot at the sale.