delivered the opinion of the court.
The relator sets forth in his petition, in substance, that, being legally qualified, he was a candidate at the last general election for the office of circuit judge in the eighteenth judicial circuit, and as such received the highest number of qualified votes cast in said circuit for that office ; that the respondent, as secretary of State, refused, and still refuses, to count up the votes given for him, as prescribed by law, and that he is remediless; and therefore prays this court to issue a peremptory writ of mandamus to compel that officer to act.
The respondent, in his answer, denies that the relator in said election received a majority of the qualified votes; and further says that on the 23d day of December, 1868, in presence of the governor, he proceeded to open, and did open, and cast up the votes given for the candidates for the office of judge of the said eighteenth judicial circuit, and ascertained and determined that Elijah Perry received the highest number of legally qualified votes in the counties composing the said circuit; and that respondent afterward, on the 12th day of January, 1869, certified to the governor of the State that the said Perry received the highest number of votes for said office, whereupon the governor issued a commission to said Perry as judge of the eighteenth judicial circuit. The facts appear to be that, in the count of the vote, two counties included in .the circuit — Shannon and Oregon — were omitted. The respondent states in his evidence that he refused to open the votes returned Rom these counties, but assigns no reason for his refusal. By the law in relation to elections (Gen. Stat. 1865, ch. 2, § 32) it is provided that *260within fifty days after each general election, and as much sooner as the returns shall all have been made, the secretary of State, in the presence of the governor, shall proceed to open the returns and to cast up the votes given for all the candidates for any office, and shall certify to the governor, under his hand and the seal of the State, the candidates having the highest number of votes, and upon that certificate the governor shall issue commissions.
The law does not seem to have vested in the secretary any discretion in the premises. It requires him to perform the act of opening and counting the returns. It is the law declared by this court, as well as the general current of. authority, that a county clerk or the secretary of State, in opening and casting up votes, acts ministerially, and not judicially. The matter of determining upon the legality of votes is a judicial function, to be passed upon before a tribunal competent to make an adjudication, where the parties interested can be heard. But, although from the case presented by the record I am of the opinion that the respondent erred, no peremptory writ can be issued.
It was decided by this court, in St. Louis County v. Sparks, 10 Mo. 117, that a mandamus could not be issued where the office was already filled by a person holding by color of right.
The object of granting the writ', says Tapping, is to prevent a failure of justice, and to provide an immediate and efficacious remedy. It follows, therefore, that it will not be granted, if, when granted, it would be nugatory. For the principle alone upon which the court exercises this prerogative power is that a strong necessity for -such remedy exists, and that without it the ends of justice will be defeated. Hence, the court will refuse it, if it be manifest that it must be vain and fruitless, or useless, or cannot have a beneficial effect. (Tap. Mand. 67.) The authorities, both English and American, all concur in and enforce this view. The writ in the present case, if issued, would be wholly useless, and would be of no benefit to the relator. The commission has already been issued to Perry, and he is holding the office by color of right. The officer derives his title to the office by virtue of his election, and the commission is prima facieevidence only. The case has passed beyond any control of this-*261court, and the only redress the relator has, if he considers himself aggrieved, is by a legal contest made in pursuance of law.
It follows, therefore, that a peremptory writ must be denied.
The other judges concur.