Such liens may be enforced by action in the district court of the county in which the improved premises or some part thereof are situated, or, if claimed under section 514.04, of any county through or into which the railway or other line extends, which action shall be begun and conducted in the same manner as actions for the foreclosure of mortgages upon real estate, except as herein otherwise provided, but the owner or any person or party having an interest in or lien upon the property against which a lien has been filed under the provisions of this chapter may bring an action to remove the lien in the nature of an action to determine adverse claims and subject to all the provisions of law regarding actions to determine adverse claims.
When an action has been brought, either by the lien claimant to enforce the lien or by the owner, person or party having an interest in or a lien upon the property against which a lien claim has been filed to determine adverse claims, as provided herein, application may be made at any time after such action has been commenced by any of the persons or parties above mentioned to have the property affected by any such lien, released from the lien by giving ten days' notice, or such other and shorter notice as the court may order and direct, to the lien claimant, or the lien claimant's attorney, of intention to apply to the district court for the release of such lien and of the time and place of hearing. Upon a hearing upon an application the court shall fix a sum of money or an amount of a bond from a surety listed on the United States Department of Treasury Circular 570 made payable upon the entry of judgment as provided in this section to be deposited by the applicant with the court administrator of the district court, which sum shall not be less than the aggregate amount of, (1) the amount claimed in the lien statement, (2) $18 for every $100 or fraction thereof, to cover interest, (3) the probable disbursements in an action to enforce the claim for which the lien statement was filed, (4) an amount not less than double the amount of attorneys' fees allowed upon the foreclosure under section 582.01, to cover any allowance the court may make upon the trial for costs and attorneys' fees in the action or upon appeal. Upon making a deposit in the amount so fixed in the order of court, an order shall be made by the court releasing the premises described in the statement thereof from the effect of such lien. The lien claimant shall have the same right of lien against such money or bond deposit as against the property released. The order releasing the lien may be filed in the office of the county recorder or registrar of titles, if registered land, of the county in which the lien statement is recorded or filed, and thereupon the premises affected shall be released therefrom. The court shall by the same order discharge any notice of lis pendens filed in any action in which such lien may be asserted if it appears that all mechanics' liens filed or recorded against the property covered by the lis pendens have been released.
After the release of the property affected, the judgment ordered in any action either to enforce such lien or determine adverse claims and remove such lien, in the event that the lien is established, shall provide that it be paid, and it shall be paid without further proceedings out of the deposit made as provided herein. The judgment of the district court establishing a lien, unless a written notice of intention to appeal therefrom is served on the court administrator of the district court within 30 days from the entry of such judgment, shall be authority to such court administrator to pay the amount specified in such judgment to the persons entitled thereto, or their attorney of record in the action from the amount of money on deposit or to allow the claimant to collect on the bond that has been deposited. The balance of the deposit of money or bond, if any, shall be returned to the depositor. If the lien was not a valid and enforceable one, the judgment shall direct the return of the whole deposit to the depositor unless the claimant obtains judgment against such depositor personally and in such case the judgment shall be paid as hereinbefore specified.