From the admissions in the pleadings and findings of fact made by his Honor, it appears that plaintiff is a corporation engaged in distributing and selling kerosene oil, gasoline, and other petroleum products, and for the purpose and with the intent of carrying on its business within the corporate limits of the town of Sanford, on 14 June, 1919, applied to the building inspector for a permit to erect in said town, on the corner of the Southern Railway right of way and Weather spoon Street, certain described surface structures, including “3 steel tanks on brick piers, 20 x 40 frame warehouse offices, pump house, etc., together *317witb all pumps, engines,- pipe lines, fences, and equipment necessary for the conduct of the company’s business.” That, owing to the fact that the city government was at the time examining into the matter with a view of determining whether this was a proper business to be carried on within the corporate limits, etc., the application was not then given. Whereupon, on 3 July, 1919, plaintiff instituted this proceedings for a mandamus to compel performance of the alleged duty. Pending the suit, the board of aldermen, having in their judgment ascertained by inquiry of the State Insurance Commissioner, the officials of adjoining towns where such structures had been erected and used, and others, that the proposed business and buildings, etc., would be highly inconvenient and annoying to adjacent owners and citizens generally, and import menace to lives and property, passed the ordinances hereinbefore set out.
In reference to the ordinances, the court finds that the business and structures on the site as designated will come within the distances prescribed and prohibited by the ordinance but, finding also that there is nothing in the plans and specifications of the buildings themselves that are violative of the general State and municipal regulations as to buildings, and being of opinion, therefore, that there was a ministerial duty permitting no discretion on the part of the inspector, gave judgment that the writ issue, and defendant, the inspector, appealed.
It is undoubtedly true that performance of a mere ministerial duty on the part of a public official, when arbitrarily refused, may be enforced by mandamus, and, under some conditions, the issuance of a building permit, under our statutes appertaining to the subject, may come within the principle. County Board of Education v. State Board, 106 N. C., 81; Hartman v. Collins, 106 N. Y. Supr. Ct., 11. But it is also fully recognized that the writ of mandamus will not be issued to enforce the performance of an unlawful act nor one in furtherance of an unlawful purpose. Betts v. Raleigh, 142 N. C., 229; Godwin v. Carolina Tel. Co., 136 N. C., 258; Hall v. State, 82 Ala., 563; Chicot County v. Kruse, 47 Ark., 80; State ex re Ry. Co. v. Latrobe, 81 Md., 223; State ex re Matheny v. County Ct. Wyoming, 47 W. Va., 672.
In Godwin v. Tel. Co. the application was to compel the installation of a telephone in a bawdy house, and it was held that the writ must not lie, and the present Chief Justice, delivering the opinion, said: “But while it is true that there can be no discrimination where the business is lawful, no one can be compelled or is justified to aid in unlawful undertakings.” And in the annotations of this case appearing in 6 Anno. Oases, 203, the general principle is stated as follows: “It is well settled that mandamus will not lie to compel the performance of acts which are illegal, contrary to public policy, or which tend to aid an *318■unlawful purpose,” citing numerous authorities. These building regulations appearing chiefly in our statute on towns, Rev., ch. 73, sec. 2896 et seq., are of general application, to be followed and allowed only when the business to be conducted therein is lawful, and are subject in this respect to the police powers conferred by this and other laws on municipal governments for the public good. State of Mo. ex re Gas Co. v. Murphy, 170 U. S., 78. In this instance, it appears that the avowed and only purpose of erecting these structures is to carry on the business of selling and distributing kerosene oil and gasoline and other petroleum products; a purpose not only evidenced by the character of the building, but so expressly stated in the complaint.
The subject is well within the governmental powers ordinarily possessed by this and other cities and towns. Hudachick v. Los Angeles, 239 U. S., 394; Reinan v. Little Rock, 237 U. S., 171, and the municipal authorities of Sanford, having formally passed ordinances by which the proposed business is made unlawful, under the principle of the decisions heretofore cited, we are of opinion that the application for mandamus should be denied. And such a defense is available though it may have arisen since the institution of the suit.
The act having become unlawful, the position may be made effective at any time pending the proceedings when it is properly brought to the attention of the Court. Williams v. Hutton, 164 N. C., 216; Brinson v. Duplin Co., 173 N. C., 137; Wikel v. Comrs., 120 N. C., 451; Hall v. State, 82 Ala., 563.
On the facts present, we are of opinion that the application must be denied, and it is so ordered.
Reversed.