EXHIBIT 5 LeBoeuf, Lamb, Greene & MacRae, L.L.P. A Limited Liability Partnership Including Professional Corporations 260 Franklin Street Boston, MA 02110 April 29, 2004 Unitil Corporation 6 Liberty Lane West Hampton, NH 03842-1720 Ladies and Gentlemen: We have acted as counsel to Unitil Corporation, a New Hampshire corporation (the "Company"), in connection with the filing of a Registration Statement on Form S-8 (the "Registration Statement") by the Company with the Securities and Exchange Commission pursuant to the Securities Act of 1933, as amended (the "Securities Act"), providing for the registration of 177,500 shares (the "Plan Shares") of the Company's common stock, no par value, to be issued pursuant to the Company's 2003 Restricted Stock Plan (the "Plan"). In connection with this opinion, we have examined originals or copies, certified or otherwise identified to our satisfaction, of such instruments, certificates, records and documents, and have reviewed such questions of law, as we have deemed necessary or appropriate for purposes of this opinion. In such examination, we have assumed, without investigation, the genuineness of all signatures, the authenticity of all documents submitted to us as originals, the conformity to the original documents of all documents submitted to us as copies and the authenticity of the originals of all such latter documents. As to any facts material to this opinion, we have relied upon the aforesaid instruments, certificates, records and documents and inquiries of Company representatives. Unitil Corporation April 29, 2004 Page 2 Based upon the foregoing examination, and subject to the limitations set forth below, we are of the opinion that the Plan Shares will be validly issued, fully paid and nonassessable when: (a) the Registration Statement shall have become, and for so long as it shall remain, effective for the purpose of the issuance and sale of the Plan Shares; and (b) the consideration therefor provided for in the Plan has been received by the Company. This opinion is rendered under and limited to the New Hampshire Business Corporation Act (without reference to "blue sky" matters) and the federal law of the United States. We consent to the filing of this opinion as Exhibit 5 to the Registration Statement and in any amendments thereto. In giving such consent, we do not thereby concede that we are within the category of persons whose consent is required under Section 7 of the Securities Act, or the rules and regulations of the Securities and Exchange Commission thereunder. Very truly yours, /s/ LeBoeuf, Lamb, Greene & MacRae, L.L.P.