
556 P.2d 520 (1976)
WESTERN PLUMBING OF BOZEMAN, and John Metcalf, d/b/a J & J Masonry, Plaintiffs and Respondents,
v.
Rupert T. GARRISON and Joan N. Garrison, Defendants and Appellants.
No. 13213.
Supreme Court of Montana.
Submitted September 2, 1976.
Decided September 17, 1976.
*521 Chester L. Jones (argued), Virginia City, for defendants and appellants.
William E. Gilbert (argued), Bozeman, for plaintiffs and respondents.
HASWELL, Justice.
In an action to foreclose liens for labor and materials, the homeowners paid the amounts claimed with interest after the suit was filed but prior to trial. The lienholders proceeded to trial thereafter and secured judgment for attorney fees. The homeowners appeal.
The homeowners, Rupert T. Garrison and Joan N. Garrison, were having a home constructed for them in Madison County in 1974. In the summer and fall of that year they entered into an agreement with Western Plumbing of Bozeman, Inc., one of the lienholders, whereby Western was to install a furnace, plumbing system and fixtures for three baths and a kitchen in this residence. The agreement was for the reasonable value of labor and materials furnished with no specific agreement as to the time of payment. On February 19, 1975, before the entire job was completed, Western filed a lien for the labor and materials furnished up to that time in the amount of $7,500. The entire agreement had not been completed at this time because of nonarrival of certain bathroom fixtures. The complete job as agreed totaled approximately $8,800.
In 1974 the Garrisons also entered into an agreement with John Metcalf, d/b/a J & J Masonry, whereby the latter agreed to do certain masonry work on the residence including two fireplaces, four pillars, a brick and stone wall, brick flower bed and brick barbeque. The Garrisons paid $3,000 for materials for this work. Metcalf commenced work in September 1974 and quit about December 6, 1974 because of inclement weather. Metcalf never returned to complete the work and out of 14,560 bricks agreed to be laid to complete the job, he laid only 11,500 bricks. The pillars, the brick flower bed, and the brick barbeque remained unfinished. On February 19, 1975, Metcalf filed a lien for labor and materials furnished in the total amount of $6,659.08.
Actions to foreclose the liens of Western and Metcalf were filed in the district court of Madison County on March 11, 1975. On April 26, 1975, Garrisons paid and discharged all amounts owing to Western and *522 Metcalf for labor and materials, including interest. Western and Metcalf continued their foreclosure actions to the extent of seeking judgment for their attorney fees.
Trial of the consolidated claims for attorney fees was commenced on June 27, 1975, in the district court of Madison County before the court without a jury. Thereafter findings of fact, conclusions of law, and judgment was entered awarding Western $700 attorney fees, and Metcalf $600 attorney fees. The Garrisons appeal from these awards.
Two ultimate issues are presented for review:
(1) The validity of the liens;
(2) Are the lienholders entitled to attorney fees where payment is made prior to judgment of foreclosure?
The lienholders contend their liens are valid because the work was substantially completed at the time the liens were filed. They also point out the Garrisons had moved into their residence on December 26, 1974, almost two months before their liens were filed; that they had been repeatedly promised payment by the Garrisons before they filed their liens; and, if they had waited much longer to file their liens they would have lost their lien rights because of the ninety day limitation in section 45-502, R.C.M. 1947.
Additionally, the lienholders argue the intent of the legislation authorizing an award of attorney fees to lienholders is to make them whole and that if attorneys' fees would be avoided by payment of the claim after suit was filed but before judgment the salutary objective of the lien statutes would be defeated.
The homeowners, on the other hand, take the position the liens are invalid because they were filed prematurely before the agreed work was completed. Thus, they argue, an invalid lien cannot support an award of attorney fees in a foreclosure action.
Additionally, the homeowners contend that payment in full of the claims on which the liens are founded prior to judgment discharges any obligation to pay attorney fees. They also claim in their brief, that they should have been awarded their attorney's fee and had their title quieted.
Directing our attention to the first issue, we find the liens were filed prematurely and are therefore invalid. In Montana the general rule is that the lien arises only upon completion of the contracted work. Intermountain Electric, Inc. v. Berndt, 164 Mont. 67, 518 P.2d 1168. Although substantial performance of the contracted work meets this requirement, such substantial performance is a condition precedent to liability of the homeowners. Riddell v. Peck-Williamson Heating & Ventilating Co., 27 Mont. 44, 69 P. 241.
Here Western had not substantially completed its contracted work at the time the lien was filed. The manager of Western admitted at the trial that at the time the lien was filed only one of the three toilets was connected and working, the bath-tub was not hooked up, at least two wash-basins were not hooked up, and that although the rough-in plumbing was done, all the fixtures had to be set. A testimonial conflict on the time of completion of the heating contract was not resolved in the findings of the district court. Defendants' proposed finding that Western had not substantially completed its contracted work should have been adopted by the district court in its findings and failure to do so was error.
Insofar as Metcalf was concerned, the district court made specific findings that he quit the job on or about December 6, 1974, because it could not be completed due to inclement weather, never did return to complete the job; that over 3,000 bricks remained to be laid, the pillars were not built, the brick flower bed and the brick barbeque remained unfinished at the time he filed his lien. These findings demonstrate *523 there was not substantial completion of the contracted work.
The direct lien theory relied upon by the district court does not give rise to lien rights absent substantial performance of the contracted work under the facts here. This is not a case where the homeowner agreed to make periodic progress payments as the work was performed and the materials supplied; it is a case where the owner contracted to have a certain job done and pay the reasonable value of the labor and materials with no specific agreement as to the time of payment. Until the contracted work is substantially completed, no obligation to pay arises and no lien rights accrue under such circumstances.
As the liens are invalid because filed prematurely, no right to attorney fees exists. The right to attorney fees and costs is purely statutory. The applicable statute provides for the allowance of attorney fees "to each claimant whose lien is established". Section 93-8614, R.C.M. 1947. There being no valid lien in the first instance, there can be no award of attorney fees.
The lien claimants having been paid in full for the contracted work and materials with interest, no equitable basis exists for an award of attorney fees where, as here, their respective liens were invalid when filed. On the contrary, reasonable attorney fees are payable to defendants under section 93-8614, because plaintiffs' liens were not established.
The judgment of the district court is reversed. The cause is remanded to the district court for fixing a reasonable attorney fee for defendants' attorney to be paid by plaintiffs; for determination of whether defendants' title should be quieted; and for entry of appropriate judgment herein in conformity with this opinion.
JAMES T. HARRISON, C.J., and JOHN C. HARRISON and CASTLES, JJ., concur.
