Form: S-8

Initial registration statement for securities to be offered to employees pursuant to employee benefit plans

May 7, 2004


QuickLinks -- Click here to rapidly navigate through this document


EXHIBIT 5.1

EXHIBIT 5.1
[GOODWIN PROCTER LLP LETTERHEAD]

May 6, 2004

AvalonBay Communities, Inc.
2900 Eisenhower Avenue, Suite 300
Alexandria, VA 22314

    Re:
    Legality of Securities to be Registered Under Registration Statement on Form S-8

Ladies and Gentlemen:

        This opinion is furnished in connection with the registration statement on Form S-8 (the "Registration Statement") pursuant to the Securities Act of 1933, as amended (the "Securities Act"), relating to the registration of deferred compensation obligations (the "Obligations") of AvalonBay Communities, Inc., a Maryland corporation (the "Company"). The Obligations will arise under the AvalonBay Communities, Inc. Deferred Compensation Plan, as amended and restated (the "Plan"), in which a group of management or highly compensated employees of the Company may participate.

        In connection with rendering this opinion, we have examined (i) the Amended and Restated Articles of Incorporation of the Company, as amended through the date hereof, as on file with the Maryland State Department of Assessments and Taxation, (ii) the Amended and Restated By-laws of the Company, as amended through the date hereof, (iii) such records of the corporate proceedings of the Company as we deemed material, (iv) the Registration Statement and the exhibits thereto, (v) the Plan, and (vi) such other certificates, receipts, records and documents as we considered necessary for the purposes of this opinion. In our examination, we have assumed the genuineness of all signatures, the legal capacity of natural persons, the authenticity of all documents submitted to us as certified, photostatic or facsimile copies, the authenticity of the originals of such copies and the authenticity of telephonic confirmations of public officials and others. As to facts material to our opinion, we have relied upon certificates or telephonic confirmations of public officials and certificates, documents, statements and other information of the Company or representatives or officers thereof.

        We are attorneys admitted to practice in The Commonwealth of Massachusetts. We express no opinion concerning the laws of any jurisdictions other than the laws of the United States of America, the Commonwealth of Massachusetts and the Maryland General Corporation Law, and also express no opinion with respect to the blue sky or securities laws of any state, including Massachusetts or Maryland. To the extent that any other laws govern any of the matters as to which we express an opinion herein, we have assumed, without independent investigation, that the laws of such jurisdiction are identical to those of the Commonwealth of Massachusetts, and we express no opinion as to whether such assumption is reasonable or correct.

        Based on the foregoing, we are of the opinion that the Obligations, when established pursuant to the terms of the Plan after approval by or pursuant to the terms of authorization from the Company's Board of Directors and upon issuance and payment therefor in accordance wtih the terms of the Plan, will be duly authorized and validly issued and will be legal, valid and binding unsecured general obligations of the Company enforceable in accordance with their terms and the terms of the Plan, subject, as to enforcement, to (i) bankruptcy, reorganization, insolvency, moratorium and other similar laws and court decisions of general application, including without limitation, statutory or other laws regarding fraudulent or preferential transfers, relating to, limiting or affecting the enforcement of creditor's rights generally, and (ii) the effect of general principles of equity upon the specific enforceability of any of the remedies, covenants or other provisions of the Plan and upon the availability of injunctive relief or other equitable remedies and the application of principles of equity



(regardless of whether enforcement is considered in proceedings at law or in equity) as such principles relate to, limit or affect the enforcement of creditors' rights generally.

        This opinion shall be interpreted in accordance with the Legal Opinion Principles issued by the Committee on Legal Opinions of the American Bar Association's Business Law Section as published in 53 Business Lawyer 831 (May 1998).

        The opinions expressed herein are being furnished to you solely for your benefit in connection with the Registration Statement, and may not be used or relied upon by you for any other purpose, nor may this opinion be quoted from, circulated, relied upon or otherwise referred to, by any other person or entity without our prior written consent. This opinion is given as of the date first set forth above, and we assume no obligation to update this opinion. We hereby consent to the inclusion of this opinion as an exhibit to the Registration Statement. In giving this consent, we do not admit that we are within the category of persons whose consent is required under Section 7 of the Securities Act or the General Rules and Regulations of the Securities and Exchange Commission.

                        Sincerely,

                        /s/ Goodwin Procter LLP

                        GOODWIN PROCTER LLP

2




QuickLinks