— Order of the Supreme Court, New York County (Irma Santaella, J.), entered on February 7, 1991, which, inter alia, granted plaintiff’s motion for summary judgment, unanimously reversed, on the law, to the extent of denying plaintiff’s motion for summary judgment, denying plaintiff’s motion to dismiss defendant-appellant Target’s affirmative defenses and counterclaims, vacating the appointment of a Referee, reinstating the affirmative defenses and counterclaims, and the matter is remanded, without costs.
Plaintiff-respondent Dollar Dry Dock moved for summary judgment in this mortgage foreclosure action with respect to a first and a second mortgage it held on the same premises.
Defendant-appellant Target Builders, Inc. commenced a mechanic’s lien foreclosure action against the premises, which was consolidated for trial with the mortgage foreclosure action.
The Motion Court granted the plaintiff-mortgagee’s motion *689for summary judgment of foreclosure and held that, because the two mortgages were filed prior to the filing of the mechanic’s liens, the mechanic’s liens were subordinate. The Motion Court failed to consider whether Lien Law § 22 should apply to subordinate the bank’s mortgages to the mechanic’s lien. Issues of fact include whether the consensual foreclosure stipulation agreed upon by defendant-borrowers materially modified the original building loan agreement, and whether the defendant-subcontractors could qualify as a third party within the meaning of Lien Law § 22.
On this record summary judgment was clearly inappropriate. Discovery should proceed with respect to the affirmative defenses and counterclaims of all subcontractors. Concur— Murphy, P. J., Carro, Kupferman, Asch and Rubin, JJ.