N.M. Stat. § 48-2-12
Contractor liable for liens of subcontractors.
The contractor shall be entitled to recover upon a lien filed by the contractor only
such amount as may be due to the contractor according to the terms of the contract,
after deducting all claims of subcontractors under the contractor who have filed liens for
work done and materials furnished, and during the pendency of the action, the owner
may withhold from the contractor the amount of money for which the lien is filed unless
the lien was asserted as a result of the owner's failure to pay the contractor for work
done and materials furnished, and in case of judgment against the owner or the owner's
property upon the lien, the owner shall be entitled to deduct from any amount due or to
become due by the owner to the contractor the amount of the judgment. If the amount of
the judgment exceeds the amount due by the owner to the contractor, or if the owner
settles with the contractor in full, the owner shall be entitled to recover back from the
contractor any amount paid by the owner, in excess of the contract price, and for which
the contractor was originally the party liable.