
64 N.Y.2d 143 (1984)
Ismail Parsa, Respondent,
v.
State of New York, Appellant.
Court of Appeals of the State of New York.
Argued November 15, 1984.
Decided December 27, 1984.
Robert Abrams, Attorney-General (Betsy Broder and Peter H. Schiff of counsel), for appellant.
Morris Weissberg and Robert J. Krengel for respondent.
Chief Judge COOKE and Judges JASEN, JONES, WACHTLER, MEYER and KAYE concur.
*146SIMONS, J.
Claimant is a physician and a full-time professor of pathology at Downstate College of Medicine, a branch of the State University of New York. The State pays him a salary for his duties as professor and it pays him supplemental compensation for pathology services as a member of Downstate Pathology Associates, P. C. In this action claimant seeks further compensation for services performed in Downstate's kidney transplant program for end stage renal disease (ESRD) patients during a two-year period from April 1, 1981 to March 31, 1983. A proposed agreement between claimant and Downstate had been drafted which authorized payments of $145,000 per year for these services, but it was not executed by Downstate or approved by the State Comptroller. Downstate received Medicare benefits for ESRD patients from the Federal Government during this period, however, and paid part of them to claimant to compensate him for the services he had performed in the ESRD program. He rejected the payment as inadequate and instituted this action in the Court of Claims, claiming that the State owes him more.
Claimant's first and third causes of action are for money had and received. He alleges that a portion of the Medicare funds paid by the Federal Government to the State equalling $290,000 represented two years' compensation for his services in the ESRD program and that it rightfully belongs to him. His second and fourth causes of action seek relief in the nature of mandamus directing Downstate to comply with the Federal statute and to pay claimant $290,000 for his professional services. The State moved to dismiss the claim asserting that it failed to state a cause of action because claimant had not obtained approval of the payments by the State Comptroller as section 112 of the State Finance Law requires.[1] The Court of Claims granted the *147 State's motion, ruling that it lacked jurisdiction to adjudicate claims for money had and received and claims seeking relief in the nature of mandamus. The Appellate Division modified that order by reinstating the first and third causes of action. The court believed that Downstate was merely acting as a conduit in receiving Medicare funds representing compensation for claimant's services and that those funds belonged to him. It ruled, therefore, that claimant could assert a cause of action for money had and received, that the action was at law and within the jurisdiction of the Court of Claims and that it was not foreclosed by section 112 of the State Finance Law. It agreed that the second and fourth causes of action seeking relief in the nature of mandamus could not be maintained in the Court of Claims and that ruling is not contested.
A party contracting with the State is chargeable with knowledge of the statutes which regulate its contracting powers and is bound by them (Belmar Contr. Co. v State of New York, 233 N.Y. 189, 194). Moreover, the State's acceptance of benefits furnished under a contract made without authority does not estop it from challenging the validity of the contract or from denying liability pursuant to it (Becker & Assoc. v State of New York, 48 N.Y.2d 867, affg 65 AD2d 65; see, also, Seif v City of Long Beach, 286 N.Y. 382; McDonald v Mayor of City of N. Y., 68 N.Y. 23). Even though a promise to pay may be spelled out from the parties' conduct, a contract between them may not be implied to provide "rough justice" and fasten liability on the State when applicable statutes expressly prohibit it (see Lutzken v City of Rochester, 7 AD2d 498). The result may seem unjust but any other rule would completely frustrate statutes designed to protect the public from governmental misconduct or improvidence. The contractor's option is to withhold his services unless an agreement is executed and approved as the statutes require.
The Legislature has specified that contracts exceeding $5,000 shall not be effective unless first approved by the State Comptroller. Inasmuch as claimant's contract was neither executed by the State nor approved by the Comptroller, he may not maintain an action on it (see Becker & Assoc. v State of New York, 48 N.Y.2d 867, supra). Nor does he claim that he may. He contends that notwithstanding Downstate's failure to execute the contract or to obtain the Comptroller's approval, his claim may be maintained as an action resting on implied contract, an action for money had and received. We agree with the Appellate Division that an action for money had and received is an action *148 at law which may be maintained in the Court of Claims but we disagree that claimant has stated a right to recover under the circumstances presented. We therefore reverse and dismiss the claim.
It is important at the outset to note that the courts recognize two different types of implied contract. The first, a contract implied in fact, rests upon the conduct of the parties and not their verbal or written words. It is a true contract based upon an implied promise and therefore it is subject to the provisions of section 112 of the State Finance Law.
The second type, the type claimed here for money had and received is a contract implied in law. Although the action is recognized as an action in implied contract, the name is something of a misnomer because it is not an action founded on contract at all; it is an obligation which the law creates in the absence of agreement when one party possesses money that in equity and good conscience he ought not to retain and that belongs to another (Miller v Schloss, 218 N.Y. 400, 406-407). It allows plaintiff to recover money which has come into the hands of the defendant "impressed with a species of trust" (see Chapman v Forbes, 123 N.Y. 532, 537) because under the circumstances it is "`against good conscience for the defendant to keep the money'" (Federal Ins. Co. v Groveland State Bank, 37 N.Y.2d 252, 258, quoting from Schank v Schuchman, 212 N.Y. 352, 358). The remedy is available "if one man has obtained money from another, through the medium of oppression, imposition, extortion, or deceit, or by the commission of a trespass" (Miller v Schloss, supra, p 408). The action depends upon equitable principles in the sense that broad considerations of right, justice and morality apply to it, but it has long been considered an action at law (see Roberts v Ely, 113 N.Y. 128; Diefenthaler v Mayor of City of N. Y., 111 N.Y. 331, 337). An action for money had and received has been permitted against a public body in instances where plaintiff has paid money by mistake, money has been collected for an illegal tax or assessment, or property is erroneously taken or withheld by a public official (McDonald v Mayor of City of N. Y., 68 N.Y. 23, 29, supra; see, e.g., Niagara Mohawk Power Corp. v City School Dist., 59 N.Y.2d 262; and New York R. T. Corp. v City of New York, 275 N.Y. 258, 264, affd 303 US 573 [recovery of taxes paid under compulsion of an unconstitutional tax levy]; County of Oneida v First Citizens Bank & Trust Co., 264 App Div 212 [action by a county and its treasurer against a depositor bank to recover funds deposited in a self-insurance plan which were fraudulently paid to third parties]).
*149Subdivision 2 of section 9 of the Court of Claims Act gives that court jurisdiction to determine claims for "breach of contract, express or implied". The court had jurisdiction to adjudicate this claim for money had and received, therefore, because it states a legal cause of action for money damages founded upon an implied in law contract (see Stone v White, 301 US 532, 534-535; Matter of First Nat. City Bank v City of New York Fin. Admin., 36 N.Y.2d 87). The action is not barred by section 112 of the State Finance Law because claimant is not seeking to enforce an agreement; he is seeking to recover funds from the State which he alleges belong to him and which the State is wrongfully withholding from him. His cause of action is predicated on his claim that he is entitled to $290,000 of the Medicare funds paid by the Federal Government to Downstate and, in the language of the cases, that he has been deprived of them by "oppression, imposition, extortion, or deceit, or by the commission of a trespass" (see Miller v Schloss, supra, p 408), or by mistake or illegality (see McDonald v Mayor of City of N. Y., supra, p 29). That was the Appellate Division's view of the action, that pursuant to the Federal statutes some allocable portion of Downstate's Medicare receipts belonged to claimant and that it was merely a collecting and disbursing agent. We reverse because the Medicare statute does not give claimant any legal claim to funds paid to Downstate for his services.
Federal Health Insurance for the Aged, popularly known as "Medicare", was adopted as part of the Social Security Act of 1965. In 1978 the program was expanded to extend benefits to victims suffering from end stage renal disease so that they would be assured of adequate medical treatment in the face of skyrocketing medical costs (US Code Cong & Admin News, 1978, vol 3, Legislative History, Pub L 95-292, p 848). The Medicare program consists of two basic, substantively distinct, parts  part A providing insurance for hospital and hospital-related services (US Code, tit 42, §§ 1395c-1395i), and part B, which creates a voluntary insurance program to pay for medical and other health services, including physicians, diagnostic home health and outpatient services. Part B is available to persons age 65 and older who agree to pay monthly premiums as established by the Secretary of Health and Human Services (US Code, tit 42, §§ 1395j-1395w). Payments under part A are made only to providers, i.e., "a hospital, skilled nursing facility * * * or home health agency" (US Code, tit 42, § 1395x, subd [u]) whereas payments under part B may be made to the patient or to the patient's assignee. This claim concerns benefits paid for hospital services under the provisions of part A.
*150The rate of reimbursement to providers under part A is the lesser of "(A) the reasonable cost of such services * * * or (B) the customary charges with respect to such services" (US Code, tit 42, § 1395f, subd [b], par [1]) and reimbursement will be provided for such in-patient hospital services as bed and board, nursing services, use of hospital facilities, and "such other diagnostic or therapeutic items or services, furnished by the hospital or by others" (US Code, tit 42, § 1395x, subd [b]; see 20 CFR 405.116 [a]). Reimbursable items may include "medical or surgical services provided by a physician, resident, or intern" (US Code, tit 42, § 1395x, subd [b], par [7]; § 1395rr, subd [b], par [1], cl [A]).
For purposes of this motion we assume that claimant performed services in the ESRD program at Downstate College of Medicine between April 1, 1981 and March 31, 1983, that the services were compensable under Medicare and that Downstate received funds from the Government for them. That is not to say, however, that the State is holding funds that rightfully belong to him. The statute governs the relationship between the Secretary of Health and Human Services and providers of medical services to victims of renal disease. As a provider, the hospital was compensated for supplementary laboratory services claimant performed for it, as it was for other items included in its billing, i.e., "operating room", "radiology", "inhalation therapy", "cardiac lab", "renal dialysis", "CAT scan", "anesthesiology", etc. None of these charges, however, were made on behalf of named physicians or therapists supplying the services listed because the statute does not permit the payment of physicians' fees, as such. They were not entitled to payment under part A because they were not providers. The regulations provide that the hospital may be reimbursed for such services by receiving either sums of money representing part of staff salaries allocated to ESRD or that the Secretary also will recognize private agreements between the hospital as a cost of the provider.[2] But *151 payment for staff physicians' services are matters of private contract between the provider and the physician and whatever sums are paid over by the Federal Government, are payments to the hospital for services it supplied to the patients. Insofar as the statute refers to charges made by the provider which may include reasonable physician's services, it states a formula for computing the provider's charges, it does not set aside fees which the physician is entitled to receive as a matter of law.
In short, the State has not received nor is it holding sums of money to which claimant is entitled any more than any of the several physicians or therapists are entitled to the itemized sums listed on the hospital's bill for various services they supplied to in-patients and which, in the aggregate, constituted the hospital's total charge. Inasmuch as claimant cannot establish that the State is wrongfully withholding sums from him to which he is entitled under the Federal statute, he has failed to state a cause of action for money had and received.
Accordingly, the order of the Appellate Division should be reversed, the certified question should be answered in the negative, and the remaining claims dismissed.
Order reversed, with costs, remaining claims dismissed and question certified answered in the negative.
NOTES
[1]  Section 112 of the State Finance Law provides, in pertinent part, as follows: "2. Before any contract made for or by any state department, board, officer, commission, or institution, shall be executed or become effective, whenever such contract exceeds five thousand dollars in amount, it shall first be approved by the comptroller and filed in his office. Whenever any liability of any nature shall be incurred by or for any state department, board, officer, commission, or institution, notice that such liability has been incurred shall be immediately given in writing to the state comptroller" (as amd by L 1980, ch 468, § 1).
[2]  42 CFR 405.484 provided:

"(b) Scope and effect of agreement. Typically, contracts between hospital-based physicians and hospitals provide for the payment of an aggregate amount (in the form of a salary, a percentage arrangement, or on some other basis) to the physician for all of his services within the institution without a service-by-service itemization. Where the physician is on salary and normally spends full time in administration of departmental affairs, the full salary may be considered a reimbursable hospital cost item and Medicare will bear its proportionate share of such cost. Where a salaried physician devotes only part of his time to institutional affairs and also renders an appreciable volume of personal patient care, only part of his salary may be attributed to hospital costs since the law requires that `medical or surgical services' must be excluded in determining a hospital's reimbursable costs.
"(c) Allocation of compensation by parties. An agreement by the parties that a certain portion of the physicians' compensation will be excluded from hospital costs and will be charged to those patients who are identified in accordance with § 405.483 will be respected unless, because of the small portion of time the physician devotes to the personal care of patients, such an agreement could lead to unreasonable charges to such patients."
