EXHIBIT 5.1 [LETTERHEAD OF DAVIS POLK & WARDWELL] NOVEMBER 19, 1997 The AES Corporation 1001 North 19th Street Arlington, Virginia 22209 Ladies and Gentlemen: We have acted as counsel in connection with the Registration Statement on Form S-3 (the "REGISTRATION STATEMENT") filed by the AES Corporation (the "Company") with the Securities and Exchange Commission pursuant to the Securities Act of 1933, as amended, for the registration of the sale by the Company from time to time of up to $1,500,000,000 aggregate principal amount of senior debt securities, senior subordinated debt securities, junior subordinated debt securities and junior subordinated debt securities (the "JUNIOR SUBORDINATED DEBT TRUST SECURITIES") issued directly or to a Trust referred to below (collectively, the "DEBT SECURITIES") of the Company, common stock, par value $0.01 per share, (the "COMMON STOCK") of the Company and preferred securities (the "PREFERRED SECURITIES") of AES Trust III AES Trust IV and AES Trust V, each a statutory business trust created under the Business Trust Act of the State of Delaware (each, a "TRUST" and, collectively, the "TRUSTS") and guarantees of the Preferred Securities by the Company (the "GUARANTEES") and stock purchase contracts to purchase Common Stock (the "STOCK PURCHASE CONTRACTS") and stock purchase units, each representing ownership of a Stock Purchase Contract and Debt Securities or debt obligations of third parties (the "STOCK PURCHASE UNITS"). The senior Debt Securities are to be issued pursuant to an indenture (the "SENIOR DEBT INDENTURE") between the Company and the First National Bank of Chicago, as trustee. The senior subordinated Debt Securities are to be issued pursuant to an Indenture dated as of July 1, 1996 (the "SENIOR SUBORDINATED DEBT INDENTURE") between the Company and The First National Bank of CHICAGO, as trustee. The junior subordinated Debt Securities are to be issued pursuant to an Indenture (the "JUNIOR SUBORDINATED DEBT INDENTURE") between the Company and The First National Bank of Chicago, as trustee. The Junior Subordinated Debt Trust Securities are to be issued pursuant to an indenture (the "JUNIOR SUBORDINATED DEBT TRUST INDENTURE") between the Company the The First National Bank of Chicago as trustee. The First National Bank of Chicago in its capacity as trustee under the Senior Indenture, the Subordinated 2 Indenture, the Junior Subordinated Indenture is referred to herein as the "TRUSTEE" and the Senior Indenture, Subordinated Indenture, Junior Subordinated Indenture and the Junior Subordinated Debt Trust Indenture are referred to herein collectively as the "INDENTURES." We have examined originals or copies, certified or otherwise identified to our satisfaction, of such documents, corporate records, certificates of public officials and other instruments as we have deemed necessary for the purposes of rendering this opinion. On the basis of the foregoing, we are of the opinion that: 1. When the Indentures and any supplemental Indenture to be entered into in connection with the issuance of any Debt Security have been duly authorized, executed and delivered by the Trustee and the Company, the specific terms of a particular Debt Security have been duly authorized and established in accordance with the applicable Indenture and such Debt Security has been duly authorized, executed, authenticated, issued and delivered in accordance with the applicable Indenture and the applicable underwriting or other agreement, such Debt Security will constitute a valid and binding obligation of the Company, enforceable in accordance with its terms, except as (a) the enforceability thereof may be limited by bankruptcy, insolvency, reorganization, fraudulent transfer, moratorium or similar laws now are hereinafter in effect relating to or affecting the enforcement of creditors' rights generally and (b) the availability of equitable remedies may be limited by equitable principles of general applicability (regardless of whether considered in a proceeding at law or in equity). 2. Upon designation of the relative rights, preferences and limitations of any series of Preferred Stock by the Board of Directors of the Company and the proper filing with the Secretary of State of the State of Delaware of a Certificate of Designation relating to such series of Preferred Stock, all necessary corporate action on the part of the Company will have been taken to authorize the issuance and sale of such series of Preferred Stock proposed to be sold by the Company, and when such shares of Preferred Stock are issued and delivered in accordance with the applicable underwriting or other agreement, such shares of Preferred Stock will be validly issued, fully paid and non-assessable, enforceable in accordance with their terms, except as (a) the enforceability thereof may be limited by bankruptcy, insolvency, reorganization, fraudulent transfer, moratorium or similar laws now or hereinafter in effect relating to or effecting the enforcement of creditors' rights generally and (b) the availability of equitable 3 remedies may be limited by equitable principles of general applicability (regardless of whether considered in a proceeding at law or in equity). 3. When necessary corporate action on the part of the Company has been taken to authorize the issuance and sale of such shares of Common Stock proposed to be sold by the Company, and when such shares of Common Stock are issued and delivered in accordance with the applicable underwriting or other agreement, such shares of Common Stock will be validly issued, fully paid and non-assessable. 4. When the Guarantees have been duly authorized by the Company, the applicable Guarantee Agreement has been duly executed and delivered and the Preferred Securities have been duly issued and delivered by the applicable Trust as contemplated by the Registration Statement and any prospectus supplement relating thereto, the Guarantees will constitute valid and binding obligations of the Company, enforceable in accordance with their terms, except as (a) the enforceability thereof may be limited by bankruptcy, insolvency, reorganization, fraudulent transfer, moratorium or similar laws now or hereinafter in effect relating to or affecting the enforcement of creditors' rights generally and (b) the availability of equitable remedies may be limited by equitable principles of general applicability (regardless of whether considered in a proceeding at law or in equity). 5. When the Stock Purchase Units and Stock Purchase Contracts have been duly authorized by the Company, the applicable Purchase Contract Agreement and Pledge Agreement have been duly executed and delivered, the Stock Purchase Units and Stock Purchase Contracts will constitute valid and binding obligations of the Company, enforceable in accordance with their terms, except as (a) the enforceability thereof may be limited by bankruptcy, insolvency, reorganization, fraudulent transfer, moratorium or similar laws now or hereinafter in effect relating to or affecting the enforcement of creditors' rights generally and (b) the availability of equitable remedies may be limited by equitable principles of general applicability (regardless of whether considered in a proceeding at law or in equity). In connection with the opinions expressed above, we have assumed that, at or prior to the time of the delivery of any such security, (i) the Board of Directors shall have duly established the terms of such security and duly authorized the issuance and sale of such security and such authorization shall not have been modified or rescinded; (ii) the Registration Statement shall have been declared effective and such effectiveness shall not 4 have been terminated or rescinded; and (iii) there shall not have occurred any change in law affecting the validity or enforceability of such security. We have also assumed that none of the terms of any security to be established subsequent to the date hereof, nor the issuance and delivery of such security, nor the compliance by the Company with the terms of such security will violate any applicable law or will result in a violation of any provision of any instrument or agreement then binding upon the Company, or any restriction imposed by any court or governmental body having jurisdiction over the Company. We are members of the Bar of the State of New York and the foregoing opinion is limited to the laws of the State of New York, the federal laws of the Unites States of America and the General Corporation Law of the State of Delaware. We hereby consent to the filing of this opinion as an exhibit to the Registration Statement. In addition, we consent to the reference to us under the caption "Legal Matters" in the prospectus. This opinion is rendered solely to you in connection with the above matter. This opinion may not be relied upon by you for any other purpose or relied upon by or furnished to any other person without our prior written consent. Very truly yours, /s/ Davis Polk & Wardwell