
41 Ill.2d 387 (1968)
243 N.E.2d 831
DOLORES W. HUSZAGH, Exr., Appellee,
v.
THE CITY OF OAKBROOK TERRACE, Appellant.
No. 41121.
Supreme Court of Illinois.
Opinion filed May 29, 1968.
Rehearing denied January 29, 1969.
THOMAS F. PIERCE, of Chicago, for appellant.
FRANK E. MOSETICK, of La Grange, for appellee.
Reversed and remanded.
Mr. JUSTICE KLINGBIEL delivered the opinion of the court:
The executor of the will of a deceased city attorney brought suit against the City of Oakbrook Terrace seeking to recover the balance of fees allegedly due under a contract for special legal services. An answer was filed admitting factual allegations but denying that additional sums were owed. It prayed that the court find the agreement to be "invalid as a matter of law." The court entered judgment on the pleadings in favor of the plaintiff, and the appellate court affirmed. (Huszagh v. City of Oakbrook Terrace, 89 Ill. App.2d 115.) We granted a petition by the City for leave to appeal.
*388 The contract ordinance, passed September 12, 1962, required plaintiff's decedent to perform certain services for the City during a period ending the third Tuesday of April, 1965. He was to handle "all legal matters" relating to certain annexation proceedings then pending in the county court, represent the City in the prosecution of any appeal in the cause and in the defense of any attack on the validity of the annexation, prepare "all necessary ordinances in connection with the legal regulation and control of all matters requiring regulation and control" in the annexed territory, and "redraft any ordinances now in effect so that they have legally proper application to said annexed territory." The contract ordinance expressly provided that the specified services "are to be considered for all legal purposes as `special legal services' which are in addition to and not covered by his employment and retention as City Attorney in representing the city in handling all routine legal matters related to the general administrative affairs of the city." As compensation he was to receive (subject to a limit of $80,000) one third of the revenues accruing to the City during the period May 1, 1962, to May 1, 1965, "from municipal retail occupation taxes, municipal retail service occupation taxes, and related taxes and revenues" from business and commercial activities located on or conducted from the annexed territory.
The complaint alleges that all the services required under the contract ordinance were completed by the end of 1962, that no payments were made after December 20, 1963, and that there remains due and owing "an amount equal to one-third (1/3rd) of the sales tax collections attributable to said parcel annexed in said case, provided, however said sum does not exceed $80,000.00." An accounting was prayed. The City answered denying that one third of the sales tax collections remained due and owing. The answer stated that the City had paid the sum of $9,327.47 for services rendered from September 12, 1962, to December 31, 1962. It was *389 prayed that the court find the agreement invalid as a matter of law. A stipulation was made that one third of the additional sales tax revenues received by the City prior to May 1, 1965, would come to $9,644.69, and on motion of the plaintiff a judgment on the pleadings against the City was entered in that amount.
In affirming, the judgment the appellate court did not consider on its merits the City's contention that the contract was illegal. The contention was rejected on the ground that illegality is an affirmative defense which is waived unless specifically raised in the pleadings, and that the City's prayer that the contract be held invalid was not specific enough. In this we think the court was mistaken. As the City urges here, it is the "facts" of a defense which must be alleged with particularity, not matters of law (see section 43(4) of the Civil Practice Act, Ill. Rev. Stat. 1965, ch. 110, par. 43), and the question whether a contract is void as contrary to statute or public policy is one of law. (See Brush v. City of Carbondale, 229 Ill. 144.) In this case no factual issue existed, as the appellate court itself pointed out. Where a court is called upon to enforce a contract, the matter of its illegality may be inquired into whether or not it is set up as a defense in the answer. Cf. Pietsch v. Pietsch, 245 Ill. 454, 459; Wright v. Cudahy, 168 Ill. 86, 92.
The City says the simple objective of the agreement was to divert one third of certain sales tax revenues to the plaintiff's decedent for the period in question, thus depleting the public revenue by one third. And it is urged, inter alia, that the contract violates section 3-14-4 of the Revised Cities and Villages Act which provides in part that "No municipal officer shall be interested, directly or indirectly, in any contract, work, or business of the municipality, or in the sale of any article, whenever the expense, price, or consideration of the contract, work, business or sale is paid either from the treasury or by any assessment levied by any statute or ordinance." (Ill. Rev. *390 Stat. 1961, ch. 24, par. 3-14-4.) After careful consideration we think this bargain to pay over a portion of the City's sales tax receipts contravenes the spirit if not the letter of the statutory provisions  which are merely declaratory of the common law  prohibiting municipal officers from becoming interested, directly or indirectly, in any business of the City. We conclude that a similar result must follow. Municipal authorities cannot, under a general grant of power, adopt ordinances which infringe the spirit of a State law or are repugnant to the general policy of the State. (City of Marengo v. Rowland, 263 Ill. 531, 534.) The ordinance in the case at bar is contrary to public policy and void.
The judgment of the appellate court is reversed and the cause is remaded to the circuit court of Du Page County with directions to enter judgment for defendant.
Reversed and remanded, with directions.
