De Haven, J.
This action is based upon an order of reference made by the surveyor-general of the state referring to the superior court of Kern County a contest concerning the right to purchase certain swamp and overflowed land.
It is averred in the complaint, in general terms, that the defendant, Beaumont, filed with the surveyor-general, in 1873, his application to purchase the land in controversy, and that in 1874 a certificate of purchase was issued to him thereon, and that at the time of filing said application the land had not been surveyed or segregated as swamp and overflowed land. ’ The complaint further alleges that plaintiff, in the year 1888, filed in the office of the surveyor-general of the state his application to purchase said land, and at the same time filed a protest against the issuance of any further evidence of title based upon defendant’s application and certificate of purchase. The complaint also alleges that at the date of his application the plaintiff was, and still is, an actual settler on the land applied for, and has valuable improvements thereon, and that he possesses all the personal qualifications to entitle him to purchase the said land. It is not averred, however, that the land was surveyed at the date of plaintiff’s application. The defendant demurred to the complaint upon the general ground that it does not state facts sufficient to constitute a cause of action. The *32demurrer was sustained, and the plaintiff failing to amend, the court rendered judgment that he take nothing by the action, and that defendant recover from plaintiff his costs. The plaintiff appeals-from this judgment.
It is clear that upon the facts stated in the complaint the plaintiff was not entitled to a judgment directing the approval of his application to purchase, as it is not alleged that the land applied for was surveyed at the date it was made; but although the plaintiff may not have been entitled to all the relief demanded, still, if upon the facts alleged he was entitled to any relief against the defendant, the demurrer was improperly sustained, and the judgment in favor of defendant for his costs is erroneous. The complaint does allege facts showing the defendant’s application and the certificate of purchase issued thereon to be invalid, and consequently that he has no right by virtue thereof to acquire a patent from the state. The question is thus presented whether, in view of these facts, the judgment rendered by the court against plaintiff, and in favor of defendant for his costs, was proper. It is urged by respondent that inasmuch as the plaintiff does not show by his complaint that the land in controversy was subject to sale at the date of his application, he is not entitled to a judgment as to the validity of defendant’s application upon the facts alleged, and is therefore in no position to complain of the judgment appealed from; and this contention of respondent seems to have been upheld by this court in the case of Urton v. Wilson, 65 Cal. 11, and perhaps, also, in Millidge v. Hyde, 67 Cal. 5; and it may be that there are dicta in other cases which also support this view. The decisions, however, have not been uniform, and upon full consideration, we are of the opinion that the rule announced in Urton v. Wilson, 65 Cal. 11, should not be followed. The jurisdiction of the superior court in this class of cases is special, and is conferred by sections 3414 and 3415 of the Political Code, and when invoked, it is the duty of the court to proceed and determine the eutire contro*33versy referred to it for decision. (Garfield v. Wilson, 74 Cal. 175.) In this latter case the court also said: “ But though the plaintiff had no right to purchase the land, and even if he had not sought to purchase it, he could still contest the right of the defendants to purchase it.” This is in accordance with the law as declared in the earlier and well-considered case of Cunningham v. Crowley, 51 Cal. 128, in construing section 17 of the “Act to provide for the management and sale of lands belonging to the state” (Stats. 1867-68, p. 511), a section which does not materially differ from the above-cited sections of the Political Code. In that case, in speaking of the object and scope of the action to determine conflicts .arising in the office of the surveyor-general, the court said: “ The purpose of the action is, not to annul the certificate of location or purchase or other evidence of title, but if both of the parties are applicants for the purchase of the lands, the purpose is to procure a determination of the question as to which applicant has the better right to purchase them; or if the contest has its origin in a protest filed by a person who is not seeking to purchase the,lands from the state, the purpose of the action is to determine whether the party against whom the protest is filed has the right to purchase the lands; and the annulment of the certificate of purchase or other evidence of title is merely a consequence of the determination that the party holding it was not entitled, as against the other party, to effect a purchase of the lands. In other words, the statute provides a mode by which and the parties in whose name an action may be instituted to determine which party has the better right to purchase the lands, where there are contesting applicants, or to determine, in case of a mere protest, whether the party against whom the protest is filed is entitled to make the purchase.”
The court in this case, as well as in that of Garfield v. Wilson, 74 Cal. 175, was speaking of a contest properly originating in. the- office of the surveyor-general, *34and referred to the court for decision. It is unnecessary at this time to determine whether sections 3414 and 3415 authorize a mere volunteer not seeking to purchase the land himself, and who does not possess the personal qualifications entitling him to do so, or one who is without any interest in the land to be affected by a sale by the state, to originate a contest by filing a protest against the issuance of title to a prior applicant. This is not such a case. Upon the facts stated in the complaint, the plaintiff was a person authorized by law to initiate this contest, and it was the duty of the court to decide as to all the matters involved therein and referred to it for decision; and one question so referred was as to the right of the respondent to receive from the state a patent for the land involved in this action. It cannot be said that the plaintiff is not aggrieved by ■the failure of the court to decide this part of the controversy, and adjudge defendant’s application void. The plaintiff is an actual settler upon the land, and has valuable improvements thereon. In addition to this, he is possessed of all the- personal qualifications which would entitle him to purchase if the land were surveyed, and it is alleged that he desires to purchase it. It is clear, therefore, that he has an interest in preventing defendant from acquiring the legal title from the state. But the judgment in this case leaves the defendant free to proceed upon his present application and acquire such title, and it cannot be assumed that he may not be able to do so. A patent, although based upon an invalid application, is conclusive as against all persons other than those who .have, prior to its issuance, initiated a valid right to purchase from the state; and upon the facts alleged, the plaintiff was entitled to a judgment which would make it impossible for the defendant to clothe himself with such a title by virtue of his present application.
The judgment must be reversed, and we think it would be proper for the court to still permit the plaintiff to amend his complaint by adding thereto an aver-*35merit that the land in controversy was surveyed at the date of his application, if he so desires. t Judgment reversed.
Sharpstein, J., McFarland, J., Paterson, J., Harrison, J., Garoutte, J., and Beatty, O. J., concurred.