There was no statute authorizing the selectmen of the plaintiff town to make the contract declared on in the plaintiffs’ writ, nor has any statute been since passed ratifying or confirming that contract. The powers of towns and town officers being derived exclusively from the statutes, the contract made by the selectmen was illegal and void. While no action can be maintained on the special counts in the plaintiffs’ declaration, an action may be maintained on the count for money had and received, if the plaintiffs are able to prove the necessary facts upon a trial of the case. Inhabitants of Concord v. Delaney, 56 Maine, 204.
The rule of law is, that where the cause of action arises, ex turpi causa, from the violation of a positive law, or of public policy, and the parties are in pari delicto, the court will not enforce the agreement of the parties by compelling its execution, or the payment of damages for not executing it, or the recovery back of what has passed under it, but will leave the parties where it finds them. The object of the law is to prevent the contemplated wrong if the contract be executory, and to punish the wrong-doer by leaving him *316to the consequences of his own misconduct, if the contract be executed. Smith v. Hubbs, 10 Maine, 76 ; Nellis v. Clark, 20 Wend. 32; Burt v. Place, 6 Cow. 491; Best v. Strong, 2 Wend. 319; Benny v. Lincoln, 5 Mass. 385.
But if the parties to an illegal contract are not in pari delicto, the party who has been oppressed, or taken advantage of by the party receiving the money, may recover it back in an action for money had and received. Worcester v. Eaton, 11 Mass. 376; Bliss v. Thompson, 4 Mass. 491.
And no privity of contract between the parties is necessary to support this action, except what results from the defendants having the plaintiffs’ money, which he has no right conscientiously to retain. Mason v. Waite, 17 Mass. 553; Hall v. Marston, 17 Mass. 401.
The action for money had and received is an equitable action, and lies where the defendant has received or obtained the possession of the money of the plaintiff, which in equity and good conscience he ought to pay over to him. (But the equitable nature of this form of action is available for the defendant as well as the plaintiff; and he may go into any equitable defense and claim every equitable allowance with respect to the whole or a part of the plaintiff’s claim). 2 Greenl. Ev. § 127; Lockwood v. Kelsea, 41 N. H. 188.
In the case at bar no contract was made by, nor were any representations made to the plaintiffs, or any person authorized to act for them in the premises. There was no illegality or misconduct on their part. They are not in pari delicto* with the defendants, and are not on that account estopped from maintaining this action. Nor are they required, as a prerequisite to maintaining this suit, to place the defendants in the position they were before the contract was entered into, as they made no contract with the defendants. The selectmen, it is true, were intrusted with the money of the plaintiffs, but it was for other purposes than that contemplated in their contract with the defendants. They improvidently and without authority paid over the plaintiffs’ money to the defendants, on account of their false and fraudulent assertions and representations. *317Tlie defendants withheld from the plaintiffs the money thus wrongfully obtained. The law will not sanction their wrong by denying to the, plaintiffs the equitable remedy which they seek. In equity and good conscience, as well as in law, the money sued for belongs to the plaintiffs as fully and completely as it did before it was delivered to the defendants, unless they have equitably appropriated it in whole or in part to the benefit of the plaintiffs. Upon a trial of the cause the rights of the parties may be equitably adjusted; for, in resorting to this equitable form of action, the plaintiffs concede the equitable right of the defendants to go into every equitable defense and show on trial that, ex cequo et bono, they are not liable for the whole or any part of the plaintiffs’ demand. Eddy v. Smith, 13 Wend. 490. Case to stand for trial.
Appleton, C. J.; Cutting, Kent, Walton, and Barrows, JJ., concurred.