*128OPINION OF THE COURT
Kaye, J.Petitioners, providers of nonemergency transportation services to Medicaid recipients, by this proceeding seek to compel respondent, Commissioner of the Department of Social Services (DSS), to process their claims for transportation services rendered to Medicaid recipients without the agency’s prior approval. Petitioners acknowledge that prior agency approval is a statutory prerequisite but contend they are nonetheless entitled to have their claims processed because of an informal practice permitting them to obtain "retroactive prior approval” after the services were rendered, which respondent should either be estopped from contesting, or found to have ratified. In that there is no basis here for the application of estoppel or ratification, we affirm the order of the Appellate Division dismissing the petition.
By statute, DSS must provide Medicaid recipients with "transportation when essential to obtain care and services” (Social Services Law § 365-a [2] [j]). The statute requires that such transportation be "upon prior approval, except in cases of emergency,” and the implementing regulation states that "[pjrior authorization by the local social services official shall be required for * * * transportation when essential to obtain medical care and services, except emergency care” (18 NYCRR 505.10 [b]).
Petitioner New York State Medical Transporters Association, Inc. is an association of companies that provide nonemergency invalid coach services to Medicaid recipients. Petitioner Medicab Inc. of New York was such a company during times relevant to this lawsuit, but was disqualified from further participation in the Medicaid program because its president pleaded guilty to grand larceny in connection with fraudulent Medicaid claims. Although a stipulation would have permitted Medicab’s subsidiaries to resume services if certain conditions were met, Medicab’s present status is unclear.
It is undisputed that under the applicable New York City plan, medical transporters were not themselves permitted to obtain the requisite approval. Instead, the medical care provider was to request approval from DSS’s fiscal agent, a separate entity operating under contract with DSS. After approv*129ing a request, the fiscal agent would assign a prior approval number to the claim, which the medical care provider would then communicate to the transporter and the transporter would include on its claim form. A prior approval number did not guarantee that a claim would be paid, only that it would be processed.
Monthly calls for prior approval reached 60,000 in 1986. Because the fiscal agent was unable to respond to that volume of calls, it adopted a practice of giving "retroactive prior approvals” after services had been rendered. The record does not establish when the fiscal agent adopted that practice, or how long it was maintained, or how many patients were transported, or when — prior to May 15, 1987 — respondent learned of the practice.1
On May 15, 1987, respondent sent petitioner Association a draft letter restating the requirement that prior approval be obtained before transportation services were rendered in all nonemergency cases, and one month later sent the final version of the letter to all transportation providers in New York City. The letter reiterated that ”[i]t is the policy of the New York State Medicaid Program that all requests for non-emergency ambulance and ambulette transportation be made via the telephone Prior Approval system at Computer Sciences Corporation (CSC) prior to or on the same date as the medical service.” The letter further stated that the requirement of prior approval would be relaxed only when "extreme difficulty had been experienced by an ordering provider in getting through on the telephone to obtain a Prior Approval,” and that such "retroactive prior approval” requests could in no event be made more than 30 days after the patient had been transported.
By this proceeding, petitioners then sought to compel respondent to reinstitute the prior practice, and also to process claims for transportation that had been provided without prior approval. They do not indicate how many claims are *130involved, only that respondent denied one request made August 14, 1987 for "prior approval” of transportation provided to a patient in February 1986, and another request made June 27, 1987 for "prior approval” of transportation provided to eight patients in February 1985. While denying that portion of the petition seeking reinstitution of the practice, Supreme Court granted the petition to the extent it sought to compel processing of claims, on the ground that the DSS had "ratified the irregular procedure by its failure to end it within a reasonable time, and by its retention of the benefits resulting from petitioner’s services.” The Appellate Division reversed and dismissed the petition, concluding that there was no basis for the application of estoppel or ratification. We agree.
We have repeatedly made clear that estoppel cannot be invoked against a governmental agency to prevent it from discharging its statutory duties (Matter of Wedinger v Goldberger, 71 NY2d 428, 441, cert denied 488 US 850; Matter of E.F.S. Ventures Corp. v Foster, 71 NY2d 359, 369-370; Matter of Parkview Assocs. v City of New York, 71 NY2d 274, 282, cert denied 488 US 801; Scruggs-Leftwich v Rivercross Tenants’ Corp., 70 NY2d 849, 852). Among other reasons, to permit estoppel against the government "could easily result in large scale public fraud.” (Matter of E.F.S. Ventures Corp. v Foster, supra, at 370.) While we have not absolutely precluded the possibility of estoppel against a governmental agency, our decisions have made clear that it is foreclosed "in all but the rarest cases.” (Matter of Parkview Assocs. v City of New York, supra, at 282.)
We reject petitioners’ contention that this is such a case. First, nothing in this record suggests that the Appellate Division erred when it found that petitioners were well aware that the law required prior approval; thus, petitioners here are in an even weaker position than the petitioner in Park-view Assocs., which could have discovered the law by reasonable diligence (71 NY2d, at 282, supra). Second, we are not persuaded that the potential for public fraud is eliminated, as petitioners contend, because they seek only processing, not payment, of their claims. The possibility that collusive behavior will result if the government can be prevented from enforcing a law on the grounds that its agents excused compliance is the same, regardless of the immediacy of the expected benefit.
Finally, petitioners’ claim that "manifest injustice” will *131result if respondent is not compelled to process their claims has no foundation in this record, which does not even reveal how many claims are involved. Furthermore, the law is clear that those who deal with the government are expected to know the law, and cannot rely on the conduct of government agents contrary to law as a basis for "manifest injustice” claims (Parsa v State of New York, 64 NY2d 143, 147; Heckler v Community Health Servs., 467 US 51, 63). "Men must turn square corners when they deal with the Government” (Rock Is., Ark. & La. R. R. Co. v United States, 254 US 141, 143). Thus, the Appellate Division correctly concluded that the doctrine of estoppel is not available to allow petitioners — who have only themselves to blame — to avoid the consequences of their own knowing failure to follow the law.
No doubt recognizing the difficulty of their estoppel claim, petitioners advance the closely related doctrine of ratification, contending that respondent knew of its agent’s practice, accepted the benefits, and is therefore bound (see generally, 57 NY Jur 2d, Estoppel, Ratification, and Waiver, § 76). For much the same reason, that contention also must fail.
At the outset, ratification of an agent’s acts requires knowledge of material facts concerning the allegedly binding transaction (see, e.g., Stauss v Title Guar. & Trust Co., 284 NY 41, 45-47; Pollitz v Wabash R. R. Co., 207 NY 113, 129-130; Reuschlein and Gregory, Agency and Partnership § 30, at 74; Restatement [Second] of Agency § 91 [1958]). Here, as the Appellate Division noted, there has been no showing that respondent knew of and intentionally condoned its agent’s practice before its letters repudiating that practice. Nor does the record demonstrate that respondent retained benefits provided by petitioners. There was no evidence that the persons to whom transportation services were provided were Medicaid recipients or that that transportation was "essential to obtain care and services.”2
But petitioners’ arguments suffer from an even more fundamental flaw. Illegal contracts are not generally enforceable (Weir Metro Ambu-Service v Turner, 57 NY2d 911, 912 [regula*132tion]; Tooker v Inter-County Tit. Guar. & Mtge. Co., 295 NY 386, 390 [statute]) — a rule that applies as well to ratification. A principal cannot ratify an agent’s act that the principal itself could not have authorized (Restatement [Second] of Agency § 84 [2] [1958]; 6A Corbin, Contracts § 1532, at 806 [1962 ed]; 15 Williston, Contracts § 1786A, at 346 [3d ed 1972]; Reuschlein and Gregory, Agency and Partnership § 30, at 73).
Petitioners’ argument is that respondent ratified its agent’s act excusing compliance with the legal requirement that approval be obtained before transportation services are rendered. Neither the statute nor the regulation which imposes the requirement (Social Services Law § 365-a [2] [j]; 18 NYCRR 505.10 [b]) gives respondent discretion to excuse that legal requirement, and respondent thus could not ratify the fiscal agent’s practice of excusing compliance with the law.
The argument of the dissent that this appeal involves social legislation, that should be humanely administered (dissenting opn, at 136), misses the mark. The issue here is not whether a statute should be humanely administered so that Medicaid recipients receive its intended benefit, but rather whether those who provide certain services to Medicaid recipients should be permitted to circumvent legislative measures that help to insure against fraud on the public. The methodology by which the statutory requirement of prior approval is to be implemented may be — as the dissent suggests — a policy decision, but the statutory requirement itself is not.
Our conclusion that ratification is not available to prevent respondent from enforcing the law here is entirely consistent with our decisions holding that the principle of estoppel is not available to petitioners for that purpose. The very reasons that the doctrine of estoppel are not available apply with equal force to petitioners’ claims of ratification. If respondent could be prevented from enforcing the law on the ground that its agent had excused compliance, the possibilities for collusive behavior and large scale public fraud are not hard to imagine.
Indeed, this case demonstrates how difficult it would become to enforce the law if respondent could be prevented from adhering to legal requirements on the ground that its fiscal agent had excused compliance with the law. Petitioners’ argument that respondent ratified the practice of "retroactive prior approvals” is based, in large part, on respondent’s letters emphasizing that the legal requirement of prior approval meant exactly that. In other words, petitioner is relying on *133respondent’s efforts to enforce the law as the basis for its claim that respondent ratified a policy contrary to that law. Such a claim obviously cannot succeed.3
Accordingly, the order of the Appellate Division should be affirmed, with costs.
. The factual premise on which the dissent rests — that information concerning the "retroactive prior approvals” was in respondent’s computer files beginning in 1985 (dissenting opn, at 133-134, 135) — lacks basis in the record. There is, for example, no evidence that the logs reflecting retroactive prior approvals by the fiscal agent (dissenting opn, at 134) were ever sent to respondent. Nor is there a factual predicate for the assertion that the fiscal agent’s forms (which did not in any event reveal that there were any "retroactive prior approvals”) were entered into respondent’s computer (dissenting opn, at 134).
. There is no "undisturbed finding * * * that petitioner’s provision of transportation services inured to DSS’ benefit” (dissenting opn, at 135). The Appellate Division reversed the trial court, and in so doing rejected its ratification analysis. Proof that respondent knew of the prior approval system and accepted the benefit of it is of course central to the dissent’s position that there was an implied ratification.
. The issue of whether respondent could authorize retroactive prior approvals if requested within 30 days of the provision of services (see, dissenting opn, at 137) is not before us, and we do not address it. Nor is there any basis here for the speculation that petitioners’ voluntary provision of services without regard to the statutory requirement of prior approval could redound to the detriment of any Medicaid recipient (dissenting opn, at 137).