delivered the opinion of the court.
The appellees having built a bridge under a contract with the Anderson county court, moved the circuit court for a writ of mandamus against the presiding judge and the justices of the peace, who constituted said county court, requiring them to lay a levy according to law, to raise a sum sufficient to pay the petitioners the balance of the contract price for the building of the bridge. They alleged iii their petition that they had built the bridge according to contract; that the commissioners who had beétí áppointed to superintend the work had reported that *852fact to the court; that one third or more of the price which they were to receive still remained unpaid, and that the county court refused to pay them what was due and owing to them, or to make any provision for its payment.
1. The county court, in contracting for the building of bridges, and making levies to pay for the work, act ministerially, not judicially, and therefore,by express provision ®f the Code,may be controlled by mandamus. Civ. Code, sec. 526.The presiding judge and the justices of the peace filed an answer, contesting the jurisdiction of the circuit court, denying that the plaintiffs had built the bridge according to the terms of the contract, and alleging that the work was so imperfectly executed that the bridge was unsafe, and failed to accomplish the purpose for which it was constructed. They specified several deficiencies in the work, and alleged that the commissioners appointed to superintend it had been induced by the fraudulent representations of the plaintiffs, to report that the work was. completed according to contract, when in truth and in fact the bridge was so badly constructed that it was of no value whatever. They therefore claimed damages by way of counter claim against the plaintiffs for a breach, of their contract.
The circuit court decided that the county court was bound to pay the plaintiffs the balance of the contract price, dismissed the counter claim without prejudice, and awarded a peremptory mandamus. From that judgment the defendants have appealed to this court.
The first question to be considered, is whether the circuit court has jurisdiction to award a mandamus in a case like the present. It is contended on the part of the appellants, that the law on this subject has been changed by the Code of Practice, and that now, under the operation of the 526th sec. of the Code, such a writ can only issue against an executive or ministerial officer, and not against an inferior judicial tribunal. It must be recollected, however, that the members of the county court, in contracting for the building, of bridges, and in laying a levy to pay for the work, are acting ministerially and not in a judicial capacity, and are therefore expressly embraced *853by the provisions of the Code. Consequently, the jurisdiction of the circuit court, to hear the application and to award the writ, if it were authorized by the testimony, was unquesti'onable.
2. In a proceeding by mandamus, to compel the county court to levy money and pay for building a bridge, a counterclaim cannot be set up by the county court to recover back money already paid on the contract; but as a defense a defective performance of the work may be relied on as a reason why the county should not pay for the wort done. 3 ona r ceedingbymandamus, the defendants are to state the reason why they have failed to do that which is sought to be enforced by the mandamus. If a sufficient reason-is given, the mandamus can not be made peremptory. If the contract has not been performed according to contract,nor the work received, as completed, the writ of mandamus will not issue.*853In a proceeding of this kin<j, a counter claim to recover back the money that has been paid on the contract is not proper. But if the petitioners have not complied with their contract, and the work has been unskilfully or imperfectly executed ‘that matter may be relied upon as a reason why the defendants should not be compelled to pay the balance of the price.
We think the conclusion is irresistible, from a consideration of all the testimony, that the bridge was not built according to the contract; that it has been both unskilfully and imperfectly constructed, and that it is in its present condition, of very little value or advantage to the county.
It is contended, however, that the plaintiffs are liable for a breach of their contract, if they have not complied with it, and that the county court ought to be compelled to pay the stipulated price, and resort to an action against the plaintiffs for the recovery of such damages as may have been sustained by their failure to fulfil their part of the contract.
On such a motion, the defendants are required to state the reasons for their refusal to pay the plaintiffs’ demand. If their reasons be suffiicient, the motion cannot be sustained. Here they have proved that the bridge as built, is not actually worth as much as has been already paid to the plaintiffs for the building of it; that it is essentially defective, both in workmanship and materials, and that the plaintiffs are not justly entitled to any additional compensation for its construction. Under these circumstances the plaintiffs’ motion should have been dismissed, unless the defendants have done some act by which they are precluded from relying upon this defense.
The commissioners who had been appointed by the county court to superintend tbe building of the *854bridge, and to report its completion when done, made a report, in which they stated that the work was completed, and that it had been performed according to contract, with some additions to the original plan, which were deemed necessary and proper. The report was received, and an order entered by the court at the same time, making an appropriation for the payment of the additional work. But no entry was made by the court acknowledging that the bridge was completed, or that the work had been performed according to contract. The court could not have properly made any such entry, as the contractors then stated in the presence of the court, that the bridge was not fully finished, althpugh the commissioners had reported that it was. And it is proved by the commissioners, that in making their report they relied upon the representations of the plaintiffs, that the work had been done according to contract. It does not appear therefore that the county court ever received the bridge, or did any act which precluded them from controverting the right of the plaintiffs to the balance of the stipulated price. The report of the commissioners, considering the circumstances under which it was made, cannot be allowed to have this effect, even if it should in a case where it was made by them upon a personal examination of the work.
If this had been a contract between individuals, the defendants could have relied, by way of defense, to the action on the failure of the plaintiffs to perform their part of the agreement. The defense would, it is true, in such a case, have assumed the form of a counter claim. But we cannot perceive any good reason why such a defense, so far as it is used for the purpose of defense merely, cannot be relied upon ip such a case as this. The proceeding is resorted to as a remedy to enforce the contract, and the defendants should not, because of the peculiar character of the proceeding, be placed in a worse attitude than they would be if they were individually responsible *855upon the contract, so that an ordinary action could be maintained against them. It seems to us, therefore, that the appellants had a right to rely upon this defense, and should not be required to pay the contract price, and resort to an independent action against the plaintiffs for a violation of the contract.
Wherefore, the judgment is reversed, and cause remanded, with directions to overrule the motion, and dismiss the petition of the plaintiffs..