Demurrers to complaint, and appeal from ■order overruling the same. The grounds relied upon in support of the demurrers in this court are insufficiency in the facts stated to constitute a cause of action, and an improper .joinder of two distinct causes of action which are not authorized to be united in the same complaint. In respect to the first ground, the demurrers being general, if the facts stated, ■or any of them, entitled the plaintiff to any portion of the *180relief sought, they were properly overruled. As to the lands-in controversy lying west of range 31, the defendant company, so far as the complaint shows, has never had any rightful claim to any estate or interest therein entitling it to any conveyance of the legal title thereto from the state, for it is-distinctly averred that it has never built any road west of St. James, which is east of range 32, but that it has abandoned, any line or pretended line of road west of that point.
As to those lands, therefore, there is nothing in the complaint tending to show the existence of any conflict between the companies by reason of the location of their respective lines of road, or any rightful authority in the governor to convey the legal title thereto from the state to the defendant, company. According to its averments, these lands, with others, were granted in prcesenti by the United States to the territory and state of Minnesota, by acts of congress of March 3, 1857, and March 3, 1865, subject to certain therein designated terms and conditions, for the purpose of “aiding the contraction of a line of railroad from Winona via St. Peter to a point on the Big Sioux river, south of the forty-fifth parallel of north latitude.” The state accepted the grant and the trust thereby created, and afterwards, upon certain specified conditions, transferred the same to the plaintiff company, together with all its interest and estate therein, both present and prospective. Upon compliance with such conditions, the plaintiff was to acquire title to the lands in parcels as specified portions of its line of road were completed, with regular trains of cars running thereon; and, as evidence of such title, it was entitled to receive, and it was made the duty of the governor to give, for and in the name of the state, a deed in fee simple thereto, whenever demanded and as fast as earned. The road has been located with the approval both of the United States- and the state, and fully completed and put in operation, with regular trains of cars running thereon, and all the conditions and requirements of the acts of congress and of the legislature-of the state in relation thereto have been complied with on the-*181part of the plaintiff, entitling it, as is alleged, to the lands so granted as aforesaid in aid of its construction. It is also further alleged, in substance, that the lands have been properly ■certified to the state, and that, since the making of the grant ■and its transfer to the plaintiff, and subsequent to the definite survey and location of the said line of road, by which the boundaries of the grant became fixed and certain, the defendant company has acquired and now holds the legal title to said lands, under a deed from the state, duly executed by its governor, who was authorized by its laws, as is alleged, to deed and convey to the railroad companies respectively entitled thereto all lands granted by the United States to the state to aid in the building of this and other railroads.
Upon the facts stated, the state acquired a perfect legal title to the lands in question upon the definite location of plaintiff’s line of road, and before the alleged conveyance of the same by deed to the defendant company. Schulenberg v. Harriman, 21 Wall. 44; Leavenworth, etc., R. Co. v. United States, 92 U. S. 733, 741, 749; French v. Fyan, 93 U. S. 169. The conditions annexed to the congressional grants, and those affixed to the transfer by the state to the plaintiff, have both been fully complied with, and therefore the plaintiff is justly and legally entitled to the lands, and to receive from the governor a proper deed of conveyance as the evidence of its title, in accordance with the express terms of the contract under which it undertook the construction of the road, and the performance of the conditions imposed upon it by the transfer from the state. Instead of this, however, the governor, acting for and in behalf of the state — as under its laws he apparently had the right to do — has given such deed to the defendant company, and thereby conferred upon it the prima-facie evidence of the legal title to the lands which wras in the state, when, in equity and in good conscience, they belonged to the plaintiff. As the invalidity of the conveyance is not disclosed upon the face of the instrument, it evidently creates a cloud upon the title which plaintiff acquired under *182the legislative grant from the state that is within the jurisdiction of a court of equity to remove.
It is immaterial whether, in the execution of the deed to the defendant company, the governor erred through fraud, ignorance, mistake of fact or a misconstruction of the law. Upon the facts alleged, and admitted by the demurrers, the defendant company, without any legal or equitable claim, has acquired and is now holding the legal title to the property, which, under the laws of congress and of this state, equitably belongs to the plaintiff. This is sufficient ground upon which to invoke the equitable powers of the court, for the purpose of converting the former into a trustee for the latter. The doctrine upon this subject is thus stated by Mr. Justice Field, in Stark v. Starrs, 6 Wall. 402, 419 : “Where one party has acquired the legal title to property to which another has a better right, a court of equity will convert him into a trustee of the true owner, and compel him to convey the legal title.” In further support of this doctrine see Lindsey v. Hawes, 2 Black, 554; State v. Bachelder, 1 Wall. 109; Johnson v. Towsley, 13 Wall. 72; Samson v. Smiley, 13 Wall. 91.
As plaintiff’s cause of action thus rests upon an equitable basis, sufficient for its support, no valid objection can be urged against compelling the defendant in the same action to account for the proceeds of such of the lands as it may have already sold, for it is a familiar principle in equity that “whenever jurisdiction once' rightfully attaches, it shall be made effectual for, the purposes of complete relief. ” 1 Story Eq. Jur. § 64 7c. There is no improper joinder of causes of action. Both claims are connected with the subject of the action — the lands — the legal title to which has been acquired by defendant, though equitably belonging to plaintiff, and both affect the defendant in its character as trustee by operation of law. The statute expressly authorizes them to be united in the same complaint. Gen. St. e. 66, § 98, subd. 1, 7.
Order affirmed.