1 EXHIBIT 5.1 December 21, 1998 MASSBANK Corp. 123 Haven Street Reading, MA 01867 Re: Registration Statement on Form S-8 ---------------------------------- Ladies and Gentlemen: This opinion is delivered in our capacity as counsel to MASSBANK Corp., a Delaware corporation (the "Company"), in connection with the preparation and filing with the Securities and Exchange Commission under the Securities Act of 1933, as amended (the "Act"), of a Registration Statement on Form S-8 (the "Registration Statement") relating to an additional 170,000 shares (the "Shares") of the Company's common stock, par value $1.00 per share ("Common Stock"), which the Company may issue pursuant to the Company's Amended and Restated 1994 Stock Incentive Plan (the "Plan"). As counsel for the Company, we have examined copies of the Plan, the Company's Restated Certificate of Incorporation and the Company's By-laws, each as presently in effect, and such records, certificates and other documents of the Company as we have deemed necessary or appropriate for the purposes of this opinion. We are attorneys admitted to practice in The Commonwealth of Massachusetts. We express no opinion concerning the laws of any jurisdiction other than the laws of the United States of America, The Commonwealth of Massachusetts and the General Corporation Law of the State of Delaware. Based on the foregoing, we are of the opinion that upon the issuance and delivery of the Shares against payment therefor in accordance with the terms of the Plan, the Shares will be legally issued, fully paid and non-assessable shares of the Company's Common Stock. The foregoing assumes all requisite steps will be taken to comply with the requirements of the Act and applicable requirements of state laws regulating the offer and sale of securities. We hereby consent to the inclusion of this opinion as an exhibit to the Registration Statement. Very truly yours, /s/ Goodwin, Procter & Hoar LLP GOODWIN, PROCTER & HOAR LLP