delivered the opinion'of the Court:
The right of selection conferred upon the railroad company is a contractual right created by the act of Congress between the United States and the company. Considering the nature of the statutory contract thus created, the court, in the case of Burke v. Southern P. R. Co. 234 U. S. 669, 680, 58 L. ed. 1527, 1544, 31 Sup. Ct. Rep. 907, speaking through Mr. Justice Van Devanter, said: “Instead of giving a gratuitous reward for something already done, the act made a proposal to the company to the effect that if the latter would locate, construct, and put into operation a designated line of railroad, patents would be issued to the company confirming in it the right and title to the public lands falling within the descriptive terms of the grant. The purpose was to bring about the construction of the road, with the resulting advantages to the government and the public, *383and. to that end provision was made for compensating the company, if it should do the work, by patenting to it the lands indicated. The company was at liberty to accept or reject the proposal. It accepted in the mode contemplated by the act, and thereby the parties were brought into such contractual relations that the terms of the proposal became obligatory on both. Menotti v. Dillon, 167 U. S. 703, 721, 42 L. ed. 333, 339, 17 Sup. Ct. Rep. 945. And when, by constructing the road and putting it in operation, the company performed its part of the contract, it became entitled to performance by the government. In other words, it earned the right to the lands described.”
It will be observed that the act of Congress under which the land in question was withdrawn as a power site was enacted and withdrawal made after selection by plaintiff company but while the list was awaiting approval by the Secretary of the Interior. The principal question presented, therefore, is, When does a vested interest in the railroad company attach to indemnity lands,—at the date of selection or at the date of approval ? This question has been before the Supreme Court of the United States in many cases. Ryan v. Central P. R. Co. 99 U. S. 382, 25 L. ed. 305; Grinnell v. Chicago, R. I. & P. R. Co. 103 U. S. 739, 26 L. ed. 456; Kansas P. R. Co. v. Atchison, T. & S. F. R. Co. 112 U. S. 414, 28 L. ed. 794, 5 Sup. Ct Rep. 208; St. Paul & S. C. R. Co. v. Winona & St. P. R. Co. 112 U. S. 720, 28 L. ed. 872, 5 Sup. Ct. Rep. 334; Barney v. Winona & St. P. R. Co. 117 U. S. 228, 29 L. ed. 858, 6 Sup. Ct. Rep. 654; Sioux City & St. P. R. Co. v. Chicago, M. & St. P. R. Co. R. Co. 117 U. S. 406, 29 L. ed. 928, 6 Sup. Ct. Rep. 790; Wisconsin C. R. Co. v. Price County, 133 U. S. 496, 33 L. ed. 687, 10 Sup. Ct. Rep. 341; United States v. Missouri, K. & T. R. Co. 141 U. S. 358, 35 L. ed. 766, 12 Sup. Ct. Rep. 13 ; New Orleans P. R. Co. v. Parker, 143 U. S. 42, 36 L. ed. 66, 12 Sup. Ct. Rep. 364; Hewitt v. Schultz, 180 U. S. 139, 45 L. ed. 463, 21 Sup. Ct. Rep. 309; Clark v. Herington, 186 U. S. 206, 46 L. ed. 1128, 22 Sup. Ct. Rep. 872; Oregon & C. R. Co. v. United States, 189 U. S. 103, 47 L. ed. 726, 23 Sup. Ct. Rep. 615.
An examination of the above cases discloses considerable un*384certainty as to the exact date when the right of a railroad company attaches under an indemnity selection. In referring to the date, the court, in some instances, uses the term “selection;” in others, “selection under direction of the Secretary of the Interior,” and in others, “selection with the approval of the Secretary of the Interior.” A careful analysis of these decisions, however, discloses an agreement of opinion that the controlling date from which the prior rights of contesting claimants attach is the date of selection. Of course, that these selections should be made “under the direction” or “with the approval” of the Secretary is important for the protection of the government. After a selection list has been filed, it remains for the Secretary, in his general supervisory capacity over the disposal of the public lands, to investigate and determine whether the lands are subject to selection under the act, and whether the company is entitled to make a selection. But this investigation and approval have nothing to do with fixing the date when the railroad company’s interest vests, any more than in the case of a homestead entryman whose interest vests from the date of making final proof and receiving his final certificate from the officials of the local land office. The duty still remains in the Secretary of examining into the question of whether or not the homesteader lias complied in good faith with the requirements of the law; but when it is found that he has, nothing remains for the Secretary but the ministerial act of issuing a patent, which evidence of title relates back to the date of the final certificate.
Indeed, this power of direction or approval by the Secretary of the Interior in the railroad land grants would have existed without any statement to that effect in the acts of Congress. “It may be laid down as a general rule that, in the absence of some specific provision to the contrary in respect to any particular grant of public land, its administration falls wholly and absolutely within the jurisdiction of the Commissioner of the General Land Office, under the supervision of the Secretary of the Interior. It is not necessary that with each grant there shall go a direction that its administration shall be under the authority of the Land Department. It falls there unless there°is express *385direction to the contrary.” Catholic Bishop v. Gibbon, 158 U. S. 155, 167, 39 L. ed. 931, 936, 15 Sup. Ct. Rep. 779.
The learned justice below turned this case upon the decision in Sjoli v. Dreschelj 199 U. S. 564, 50 L. ed. 312, 26 Sup. Ct. Rep. 154. In that case the court, speaking through Mr. Justice Harlan, said: “That no rights to lands within indemnity limits will attach in favor of the railroad company until after selections made by it with the approval of the Secretary of the Interior; that up to the time such approval is given, lands within indemnity limits, although embraced by the company’s list of selections, are subject to he disposed of by the United States or to he settled upon and occupied under the pre-emption and homestead laws of the United States; and that the Secretary of the Interior has no authority to withdraw from sale or settlement lands that are within indemnity limits which have not been previously selected, with his approval, to supply deficiencies within the place limits within the company’s road.”
This language seems on first impression to he conclusive of the point under consideration, and seems to have so affected the rule of procedure established in the Land Department that the Secretary called upon the Attorney General for an opinion as to the application of the decision. The Attorney General (25 Ops. Atty. Gen. 632) directed that the decision should he applied only to cases where the facts were similar to those in the Sjoli Case. This brings us to the facts in the case. Sjoli settled, erected buildings, and moved bis family onto the land in 1884. In 1889 he applied to the local land office to make entry of the land under the Homestead .Laws, The application was rejected because the land was then erroneously supposed to he within the granted limits of the St. Paul, Minneapolis, & Manitoba Railroad Company. Sjoli, still residing upon the land, in 1895, “relying,” as stated in the.opinion, “upon his settlement in 1884,” again applied to enter the land under the Homestead Act, and was accepted. Thereafter he made final proof, and in due course a patent was issued to him. In 1885, one year after settlement by Sjoli, the railroad company included this laud in an otherwise valid indemnity selection. Thereafter *386it sold the land to Dreschel, who brought the suit. On this state of facts, light is thrown upon the .decision. Sjoli was a settler' on the land at the date the railroad company filed its selection, a settlement which was never abandoned. He had acquired a prior right over the railroad company. His right to make a homestead entry of the land, and by compliance with the requirements of the Homestead Laws have the inchoate title initiated by settlement ripen into a valid title, dated from the time of settlement, a year before the railroad company made its selection. The decision is, therefore, in accord with both former and subsequent decisions that a settler on indemnity railroad lands at the date of selection by the railroad company has the prior right. The language used in the decision as to the date when a vested interest attaches was unnecessary to a determination of the case.
The question here involved of the exact date on which the interest of a railroad company vests in lands embraced in a valid indemnity selection was for the first time squarely decided in the case of Weyerhaeuser v. Hoyt, 219 U. S. 380, 55 L. ed. 258, 31 Sup. Ct. Rep. 300. The court, speaking through Mr. Chief justice White,' said: “It is beyond dispute on the face of the granting Act of July 2, 1861, chap. 217, 13 Stat. at L. 365, 367, and of the joint resohrtion of May 31, 1870, chap. 67, 16 Stat. at L. 378, extending the indemnity limits, that it was the purpose of Congress in making the grant to confer a substantial right to land within the indemnity limits in lieu of lands lost within the place limits. * * * The right to select within indemnity limits was conferred to replace lands granted in place which were lost to the railroad company because removed from the operation of the grant of lands in place by reason of the existence of the rights of others originating before the definite location of the road. The right to select within indemnity limits excluded lands to which rights of others had attached before the selection, and hence simply required that the selection when made should not include lands which at that time were subject to the rights of others. The requirement of approval by the Secretary consequently imposed on that official *387the duty of determining whether the selections were- lawful at the time they were made, which is inconsistent with' the theory that anyone could appropriate the selected land pending action by the Secretary.”
The facts there were that the Northern Pacific Railroad Company filed an indemnity selection list covering the land in suit, which was erroneously canceled by order of the Secretary of the Interior. Thereafter one Jones applied to purchase the land under the Timber and Stone Act, made final proof, paid the purchase price, and received a receipt from the local land office. The error in canceling the selection list was occasioned by a misapprehension of the Secretary as to the location of the eastern terminus of the Northern Pacific Railroad, which was finally determined in Doherty v. Northern P. R. Co. 177 U. S. 421, 44 L. ed. 830, 20 Sup. Ct. Rep. 677. Following this decision the Secretary canceled the entry of Jones, reinstated the lists of selection previously filed, and patented the lands to the railroad company. The railroad company conveyed the land to Weyerhaeuser, and Jones conveyed his interest to Hoyt. Hoyt began suit on the ground that Weyerhaeuser held the title in trust for him. The circuit court of appeals for the eighth circuit sustained Hoyt’s contention upon the authority of the decision in the Sjoli Case.
The decisions in the Sjoli and Weyerhaeuser Oases seem at first blush to be in direct conflict,—the .former decision holding that the right of the railroad company attaches under a valid indemnity selection at the date of approval by the Secretary of the Interior, the latter decision that it attaches on the date of filing the selection list. This apparent conflict is conclusively disposed of in the Weyerhaeuser decision, here the chief justice reviews the cases prior to the Sjoli decision, and, after stating the facts in that case, concludes as follows: “What we have already said as-to the Sjoli Oase would suffice to dispose of the suggestion concerning that case, but we shall recur to it. As to the other cases, it would be adequate to say that not one of them involved the question here under consideration, nor even by way of obiter was an opinion expressed on such question. *388Indeed, all the cases relied upon may be placed in one of three classes: (a) Those involving the nature and character of the right, if any, to indemnity lands prior to selection; (b) whether such lands, after the filing of a list of selections and before action by the Secretary of the Interior thereon, could be taxed by a State to the railroad company as the owner thereof; and (c) those which were concerned with the nature and character of acts which were adequate to initiate a right to public land which would be paramount to a list of selections when the acts were done before the filing of the list of selections. In none of the cases, moreover, was the well-settled doctrine of this court as to relation, even by remote implication, questioned. Indeed, in most of the cases relied upon, the previous decisions to which we have referred expounding the doctrine of relation, were approvingly cited or expressly reaffirmed. The Sjoli (Jase, from the facts we have already stated, is clearly here inapplicable, because it falls in the third of the above classes. If it be conceded that general language was used in the opinion in that case which, when separated from its context and disassociated from the issues which the case involved, might be considered as here controlling, that result could not be accomplished without a violation of the fundamental rule announced in Gohen v. Virginia, 6 Wheat. 399, 5 L. ed. 290, so often since reiterated and expounded by this court, to the effect that ‘general expressions in every opinion are to be taken in connection with the case in which those expressions are used. If they go beyond the case, they may be respected, but ought not to control the judgment in a subsequent suit when the very point is presented for decision.’ The wisdom of the rule finds apt illustration here when it is considered that not even an intimation was conveyed in the Sjoli Case of any intention to. overrule the repeated prior decisions of this court concerning the operation and effect of the doctrine of relation upon the approval, by the Secretary of the Interior, of a lawful list of selections. That the general expressions in the Sjoli Case are not persuasive here clearly results from the demonstration which we have previously made *389that to apply them would be in effect to destroy the indemnity provisions of the granting act.”
The contention that we are without jurisdiction in this case to control the action of the Secretary by injunction is without merit. The discretionary power of the Secretary is not involved. The indemnity list is conceded to be in regular form and to contain land lawfully subject to selection by the railroad company on the date the list was filed in the land office. Rejection and cancelation of the selection list have been ordered because subsequent to selection the land was attempted to be withdrawn by executive order for a water-power site. This selection being in every respect lawful, the act of Congress conferred upon the railway company the right to make it, and upon the Secretary the duty of approving it, and accordingly issuing a patent therefor. His discretion ceased with the finding that the selection had been lawfully made. All further duties were merely ministerial, and the situation could not be changed by invoking the aid of the intervening Rower-Site Act and executive order. The rights of the railroad company had become vested by operation of law, and could not be devested without due compensation either by an act of Congress, or by an executive order.
To hold that discretionary power exists in the Secretary to reject or cancel a selection list of indemnity lands conceded by him to have been valid at the date of filing the list in the land office would be equivalent to vesting him with power to disregard an express mandate of Congress. Congress has provided in different ways for the disposition of the public lands, and to hold that when strict compliance has been made with the requirements of the law, the Secretary still has discretion to deny rights acquired thereunder, would be equivalent to endowing him with the power to disregard the law and devest the citizen of rights expressly conferred by law.
In the case of Daniels v. Wagner, 237 U. S. 547, 59 L. ed. 1102, L.R.A.1916A, 1116, 35 Sup. Ct. Rep. 740, Ann. Cas. 1917A, 40, where a lieu-land application, in every respect in compliance with the law, was made, and, while pending approval by the Secretary, other entries were permitted to be made, the *390question of the discretionary power of the Secretary of the Interior in public land matters was exhaustively considered. Since the situation there in respect of discretionary power was on all fours with the present case, we feel justified in quoting at some length from the opinion of Chief Justice "White as follows: “This brings us to determine whether the Land Department had a right to reject a prior lieu-land entry or entries and award the land to subsequent and subordinate applicants under the assumption that it possessed a discretionary right to do so, an authority the possession of which was sustained by both the courts below. In primarily testing the proposition from the point of view of principle it is well at once to exactly fix its true import. In doing so it is to be conceded (a) that the act of Congress gave the right to one whose land had come to be included by operation of law in a forest or other reservation to apply to the Land Office and obtain the right to enter an equal amount of public land upon the surrender to the United States of the land situated in the reservation and upon the doing and offering to do everything required by the law or the lawful regulations of the Land Department to be done or offered to be done for that purpose ; (b) that in the particular case the application to enter the lieu land came within the grant of the statute, and all that was required by law or lawful regulation was done by the applicant in order to obtain entry, and (c) that it was the plain duty of the proper authorities of the Department on the filing of the entry in due course under the law to grant it. When these conclusions are accepted, it results that the claim of discretionary power is substantially this: That in a case where under an act of Congress a right is conferred to make an application to enter public land and a duty imposed upon the Department to permit the entry, the Department is authorized in its discretion to refuse to allow that to be done which is commanded to be done, and thus deprive the individual of the right which the law gives him. And it becomes moreover certain that the necessary result of this assertion is the following: That although Congress may have the power to provide for the disposition of the public domain and fix the terms and conditions upon which the *391people may enjoy the right to purchase, it has not done so, since every command which it has expressed on this subject may be disregarded and every right which it has conferred on the citizen may be taken away by an unlimited and undefined discretion which is vested by law in the administrative officers appointed for the purpose of giving effect to the law. When the true character of the proposition is thus fixed, it becomes unnecessary to go further to demonstrate its want of foundation.”
It follows from a review of the decisions, and especially of the Weyerhaeuser and Daniels Oases, that the right of a railroad company under an indemnity selection is to be determined from the status of the land at the date of selection, and where, as in this case, the selection is in all respects lawful at the time it is made, the right of the company attaches as of that date. The language used in the granting acts—-“under the direction off’ or “with the approval of” the Secretary of the Interior— merely relates to the general supervisory power of the Secretary to determine whether the selections were lawfully made and, if so, to approve and issue a patent for the lands selected. The discretion of the Secretary being limited to a determination of the right of the railroad company to make a selection and whether or not the land selected meets the requirements of the granting act, is follows, when the selection is found to bo, in all respects within the provisions of the act, discretion at that moment ceases, and nothing remains for the Secretary but the ministerial duty imposed by the conditions of the act of approving for patent.
11, is vigorously urged by counsel for the government that since patent had not passed from the United States to plaintiff railroad company for the land in question, title still remained in the government, and it was wfiildn the power of Congress to withdraw' the land, and thus destroy plaintiff’s claim. It is undoubtedly true that Congress may do with the public lands as it deems proper. It may withdraw from settlement, grant, or purchase any portion of it, so long as it remains public domain, and adverse rights have not vested. But it by no means follows that this right of withdrawal continues until title passes *392by issue of a patent. It continues until the purchaser or grantee, as in this instance, complies with all the required prerequisites which would entitle him to a patent. When that is done, a property right is vested which the government itself cannot take away without making due compensation. As was said in Campbell v. Wade, 132 U. S. 34, 38, 33 L. ed. 240, 242, 10 Sup. Ct. Rep. 9: “In the present case, before the act withdrawing’ the lands from sale, which was equivalent to a repeal of the act authorizing the sale, could be held to impair any vested right of the applicant, he must have done everything required by law to secure such right. Until then no contract could arise in any way binding upon the State. No contract rights of the petitioner were therefore violated by its legislation.”
As we have endeavored to point out, the railroad company has performed every duty imposed upon it by law, leaving in the Secretary onty the ministerial duty of approving the selection list and issuing a patent. By the act of Congress plaintiff company was granted a substantial'right in these indemnity lands. It was a grant of power under certain prescribed conditions to make selection of lands to reimburse it for place lands' lost by settlement or otherwise prior to the grant. The right to exercise this power of selection exists from the date of the survey of the indemnity land. When the power was lawfully exercised, as in this instance, the company had complied with all the prerequisites essential to establish its right. A contract then existed, the obligations of which could not be impaired even by Congress itself. “The United States cannot, any more than a State, interfere with private rights, except for legitimate governmental purposes. They are not included under the constitutional prohibition which prevents States from passing laws impairing the obligation of contracts, but equally with the States they are prohibited from depriving persons or corporations of property without due process of law. They cannot legislate back to themselves, without making compensation, the lands they have given this corporation to aid in the construction of its railroad. Neither can they by legis*393lation compel the corporation to discharge its obligations in respect to the subsidy bonds otherwise than according to the terms of the contract already made in that connection. The United States are as much bound by their contracts as are individuals. If they repudiate their obligations, it is as much repudiation, with all the wrong and reproach that term implies, as it would be if the repudiator had been a State or a municipality or a citizen. No change can be made in the title created by the grant of the lands, or in the contract for the subsidy bonds, -without the consent of the corporation. All this is indisputable.” Sinking Fund Cases, 99 U. S. 700, 718, 25 L. ed. 496, 501.
Though the right of plaintiff company, as we have shown, rests upon a statutory contract, the same rule is applicable as in the case of a purchaser of public lands under an act of Congress providing the terms upon which they can be disposed of to settlers by the Land Department. The supervisory power of the Secretary only extends to ascertaining whether or not there has been a full compliance with the law. When that is found, or conceded, as here, his supervisory power ceases, and the right of the settler vests. No greater power exists in Congress to interfere "with contract rights thus established. “The power of regulation and disposition, conferred upon Congress by the Constitution, only ceases when all the preliminary acts prescribed by those laws for the acquisition of the title, including the payment of the purchase price of the land, have been performed by the settler. When these prerequisites have been complied with, the settler for the first time acquires a vested interest in the premises occupied by him, of which he cannot be subsequently deprived. lie is then entitled to a certificate of entry from the local land officers, and ultimately to a patent for the land from the United States.” Yosemite Valley Case (Hutchings v. Low) 15 Wall. 77, 87, 21 L. ed. 82, 85.
It will hardly be contended that a railroad company under a land grant act acquires a property right inferior to that of an entryman upon the public domain. The railroad company in this instance contracted not only to construct its road, but *394entered, into a continuing obligation to furnish free transportation of government property and troops. It stands in the legal status of a purchaser who, by payment of the purchase price, acquires an interest of which he cannot be devested even by the government,. without due compensation.
Nor is there merit in the suggestion that this is a suit against the United States, and the court is, therefore, without jurisdiction. The term “public lands,” as used in our legislation, describes lands subject to sale or other disposition under general laws. Newhall v. Sanger, 92 U. S. 761, 23 L. ed. 769; Bardon v. Northern P. R. Co. 145 U. S. 535, 36 L. ed. 806, 12 Sup. Ct. Rep. 856; United States v. Buchanan, 232 U. S. 72, 76, 58 L. ed. 511, 514, 34 Sup. Ct. Rep. 237. It logically follows that when lands have passed out of the public domain and become vested in an individual or corporation, they are no longer property of the United States. An action, then, to compel the officers of the government to perform the duty prescribed by law in recognizing the rights so vested, is neither an action against the United States, nor an action affecting property belonging to the United States. It will not do to say that the injunction will have the effect of nullifying an executive order. If the order was made without lawful authority, it was a mere nullity and entitled to no consideration as against rights already vested. The proper remedy in such cases is by injunction. Lane v. Watts, 234 U. S. 525, 540, 58 L. ed. 1440, 1456, 34 Sup. Ct. Rep. 965.
The action here is to prevent an abuse of discretion by the Secretary growing out of a misapprehension of his duty under the law. “But the power of supervision and correction is not aq unlimited or an arbitrary power. It can be exerted only when the entry was made upon false testimony, or without authority of law. It cannot be exercised so as to deprive any person of land lawfully entered and paid for. By such entry and payment the purchaser secures a vested interest in the property and a right to a patent therefor, and can no more be deprived of it by order of the Commissioner than he can be deprived .by such order of any other lawfully acquired property. *395Any attempted deprivation in that way of such interest will be corrected, whenever the matter is presented so that the judiciary can act upon it.” Cornelius v. Kessel, 128 U. S. 456, 460, 82 L. ed. 482, 483, 9 Sup. Ct. Rep. 122.
The rule was even more positively stated in Ballinger v. United States, 218 U. S. 240, 249, 54 L. ed. 464, 468, 30 Sup. Ct. Rep. 338, as follows: “Whenever, in pursuance of the legislation of Congress, rights have become vested, it becomes the duty of the courts to see that those rights are not disturbed by any action of an executive officer, even the Secretary of the Interior, the head of a department. However laudable may be the motives of the Secretary, he, as all others, is bound by the provisions of congressional legislation.” This was but an approval of Garfield v. United States, 211 U. S. 249, 262, 53 L. ed. 168, 174, 29 Sup. Ct. Rep. 62, where the court said: “There is no piar' in our constitutional system for the exercise of arbitrary power, and if the Secretary has exceeded the authority conferred upon him by law, then there is power in the courts to restore the status of the parties aggrieved by such unwarranted action.”
The decree is reversed with costs, and the cause is remanded with instructions to enter a decree restraining defendants from rejecting and canceling plaintiff’s selection list, with directions to vacate the order withdrawing the land in suit for a power site, and to approve plaintiff’s selection for patent.
Reversed and remanded.
An appeal to the Supreme Court of the United States was allowed May 5, 1917.