Section 40D. (1) A city or town may by ordinance or by-law prohibit the erection of new structures or the replacement or substantial alteration of existing structures within the area to which airport approach regulations adopted under section forty A apply, without a permit from the administrative agency authorized to administer such regulations; but such a permit shall be issued as of right if the structure as erected or altered is in conformance with such regulations or will not constitute a greater hazard than the structure which is replaced or altered. No such permit shall be granted, except as provided in subsection (2) of this section, which would allow the structure or tree in question to be erected or allowed to grow to a greater height, or to become a greater hazard to air navigation, than when the applicable regulation was adopted.
(2) Any person desiring to erect or increase the height of any structure, or to permit the growth of any tree, in a manner not conforming to airport approach regulations adopted under section forty A, or to establish the right so to do, may apply to the administrative agency authorized to administer such regulations or, if there is no such agency, to the city council of the city or to the selectmen of the town, for a variance from the regulations applicable to his property. Such variances shall be allowed where a literal application or enforcement of such regulations would result in practical difficulty or unnecessary hardship and the relief granted would not be contrary to the public interest.
(3) In granting any permit or variance under this section to which the applicant is not entitled as of right, the administrative agency, city council or selectmen, as the case may be, may, if it deems such action advisable to effectuate the purposes of sections forty A to forty I, inclusive, and reasonable in the circumstances, so condition such permit or variance as to require the owner of the structure or tree in question to permit the city or town, at its own expense, to install, operate, and maintain suitable obstruction markers and obstruction lights thereon.