The question presented by this appeal is, whether the petitioner is entitled to costs because, as insisted, this is a special proceeding, and therefore within the provi*248sions of the act of the legislature passed in 1854 (Lams 1854, p. 593, sec. 3), which declared that costs may be allowed in the discretion of the court in special proceedings, and when so allowed shall be at the rate allowed for similar proceedings in civil actions. The learned justice who disposed of this matter thought costs should be awarded the petitioners, and allowed them. The respondent below appeals.
There is no adjudicated case in which costs have been allowed in proceedings on habeas corpus. The writ is one of right, and it has not been heretofore trammeled by any consequences other than the failure to obtain the object in view when it was applied for, which sometimes occurs. It is, nevertheless, a special proceeding when it is made returnable in court, and where, as in this case, it called into exercise the ordinary machinery of courts of law, such as the appointment of a referee to take the testimony, the examination of witnesses pro and con, and the subsequent hearing in due form in court on the whole evidence, and the decision of the court thereupon. The court of appeals have held that a certiorari to review summary proceedings between landlord and tenant was a special proceeding under the act of 1854 (supra), and that to the successful party costs might be awarded (The People agt. Boardman, 4 Keyes, 59).
In kindred matters the same doctrine has been promulgated (In the Matter of, &c., Rensselaer and Saratoga R. R. Co. agt. Davis, 55 N. Y., 145; In the Matter of Dodd, 27 id., 629; People ex rel. Van Rensselaer agt. Van Alstyne, 3 Keyes, 35, and cases cited; People ex rel. Latorre agt. O’Brien, 3 Abb. Ct. of App. Cases, 559; In the Matter of the Bowery Extension, 12 How. Pr., 99).
In the Matter of Dodd it was suggested that in order to make proceedings special under the act in question there must be a litigation in court. In this case there were proceedings by contest, as already stated, although the writ of habeas corpus is a writ of right, and sacred to the cause and principles of liberty. It may, nevertheless, be abused, or the *249remedy which it is issued to accomplish unjustly refused by the respondent. The writ, in other words, may be sued out vexatiously, or thé refusal to surrender the person detained may be equally vexatious.
Whether either of these features exist? it is for the court to judge, and hence the discretion which must be called into play before costs can be awarded.
If there be reasonable ground to warrant an application for the writ, no costs should follow. If there be reasonable ground for refusing to surrender the person, a like result would ensue. This was doubtless all considered by the legislature when the subject of special proceedings was considered and passed upon, and in view of their character, including the habeas corpus, the conclusion adopted to vest in the court conducting them a discretion to allow or disallow costs.
In this case the costs would seem to have been justly awarded, and the order granting them should be sustained.
The costé allowed embrace, however, only the items for proceedings after petition and before trial, and for trial and disbursements (55 N. Y., supra, 147).
The order appealed from must be modified in this respect, therefore, and as modified affirmed without costs.