<PAGE>

                                                                   Exhibit 10.40

                               SECOND AMENDMENT TO
                           LETTER OF CREDIT AGREEMENT

     This Second Amendment to Letter of Credit Agreement (the "Amendment") is
made as of the 10th day of November, 2006 by and between:

     THE GREAT ATLANTIC & PACIFIC TEA COMPANY, INC., a Maryland corporation (the
"Company"); and

     BANK OF AMERICA, N.A., as Issuing Bank (the "Issuing Bank").

In consideration of the mutual covenants herein contained and benefits to be
derived herefrom, the parties hereto agree as follows:

                                   WITNESSETH

     WHEREAS, the Company and the Issuing Bank are parties to a Letter of Credit
Agreement dated as of October 14, 2005, as amended by the First Amendment to
Letter of Credit Agreement dated as of October 13, 2006 (the "Letter of Credit
Agreement"); and

     WHEREAS, the Company has advised the Issuing Bank that the Company desires
to amend the Letter of Credit Agreement as provided herein.

     NOW THEREFORE, it is hereby agreed as follows:

1.   Definitions: All capitalized terms used herein and not otherwise defined
     shall have the same meaning herein as in the Letter of Credit Agreement.

2.   Amendment of the Letter of Credit Agreement. The Letter of Credit Agreement
     is hereby amended as follows:

a.   Section 1.01 of the Letter of Credit Agreement is hereby amended by the
     addition of the following new definitions, inserted in appropriate
     alphabetical order:

     "L/C Fee Rate" shall mean, as of any date of determination, the per annum
     rate, determined by reference to the average daily percentage of
     Availability attributable to the Collateral consisting of Cash and Cash
     Equivalents and Additional Collateral during the immediately preceding
     calendar quarter, as set forth in the following grid:

<TABLE>
<CAPTION>
Collateral consisting of Cash and Cash Equivalents and
Additional Collateral                                    L/C Fee Rate
------------------------------------------------------   ------------
<S>                                                      <C>
< 60%                                                    62.5 bps
> 60% and < 100%                                         37.5 bps
100%                                                     15.0 bps
</TABLE>

<PAGE>

     "Metro Inc. Securities Availability Cap" means $75,000,000.

     "Metro Inc. Securities Collateral" means the shares of capital stock of
     Metro Inc., a Quebec corporation, specified on Schedule 2 hereto.

     "Metro Inc. Securities Collateral Account" means that certain account now
     or hereafter established by the Company with Bank of America, N.A. or any
     of its Affiliates under the sole and exclusive dominion and control of the
     Issuing Bank designated as the "A&P Letter of Credit Metro Inc. Securities
     Collateral Account" containing investments constituting the Metro Inc.
     Securities Collateral, and in which account the Issuing Bank has been
     granted a Lien pursuant to the Pledge and Security Agreement.

     "Revolving Credit Facility" means the revolving credit facility maintained
     by the Company pursuant to the Credit Agreement, dated as of November 15,
     2005, by and among the Company, the other borrowers thereto, Bank of
     America, N.A., as Administrative Agent and Collateral Agent, and the other
     Lenders party thereto.

b.   The definition of "Account" in Section 1.01 of the Letter of Credit
     Agreement is hereby is deleted in its entirety and the following is
     substituted in its stead:

     ""Account" means each of the Cash Collateral Account, the Additional
     Collateral Account and the Metro Inc. Securities Collateral Account."

c.   The definition of "Availability" in Section 1.01 of the Letter of Credit
     Agreement is hereby is deleted in its entirety and the following is
     substituted in its stead:

     ""Availability" means, at any time of determination, the lesser of (i)
     $150,000,000, and (ii) an amount equal to the difference between (a) the
     sum of (1) 100% of the Cash and Cash Equivalents on deposit in the Cash
     Collateral Account and (2) as to the Metro Inc. Securities Collateral on
     deposit in the Metro Inc. Securities Collateral Account, the lesser of (A)
     50% of the market value of such Metro Inc. Securities Collateral (as
     determined by reference to the price of Metro Inc. stock as listed on the
     Toronto Stock Exchange) and (B) the Metro Inc. Securities Availability Cap
     and (3) as to each item of Additional Collateral on deposit in the
     Additional Collateral Account, the amount of such Additional Collateral
     multiplied by the Applicable Advance Rate applicable to such Additional
     Collateral and (b) the aggregate Letter of Credit Outstandings. In
     determining Availability, the Metro Inc. Securities Collateral shall be
     valued daily at the US Dollar equivalent of the value of such Metro Inc.
     Securities Collateral in Canadian Dollars."

<PAGE>

d.   The definition of "Commitment" in Section 1.01 of the Letter of Credit
     Agreement is hereby deleted in its entirety and the following is
     substituted in its stead:

     ""Commitment" means $150,000,000 or such lesser amount on account of a
     reduction thereof in accordance with the provisions of Section 2.09
     hereof."

e.   The definition of "Pledge and Security Agreement" in Section 1.01 of the
     Letter of Credit Agreement is hereby deleted in its entirety and the
     following is substituted in its stead:

     ""Pledge and Security Agreement" means the Amended and Restated Pledge and
     Security Agreement, dated as of November 10, 2006, between the Company and
     the Issuing Bank, as amended and in effect from time to time."

f.   Section 2.07(a) of the Letter of Credit Agreement is hereby amended in its
     entirety to read as follows:

     "(a) The Company and the Subsidiary Credit Parties shall pay the Issuing
     Bank promptly after the commencement of each calendar quarter (but in no
     event later than the tenth day of each calendar quarter), in arrears, a fee
     (each, a "Letter of Credit Fee") equal to the L/C Fee Rate (on the basis of
     actual number of days elapsed in a year of 360 days) of the average daily
     face amount of the Letters of Credit outstanding during the immediately
     preceding calendar quarter."

g.   Section 5.05 of the Letter of Credit Agreement is hereby amended in its
     entirety to read as follows:

     "Collateralization of Letter of Credit Outstandings. The Company shall
     cause the sum of (i) 100% of the Cash and Cash Equivalents on deposit in
     the Cash Collateral Account, (ii) as to the Metro Inc. Securities
     Collateral on deposit in the Metro Inc. Securities Collateral Account, the
     lesser of (a) 50% of the market value of such Metro Inc. Securities
     Collateral (as determined by reference to the price of Metro Inc. stock as
     listed on the Toronto Stock Exchange) and (b) the Metro Inc. Securities
     Availability Cap, and (iii) as to each item of Additional Collateral on
     deposit in the Additional Collateral Account, the amount of such Additional
     Collateral multiplied by the Applicable Advance Rate, to be at least equal
     to the Letter of Credit Outstandings. If at any time Letter of Credit
     Outstandings exceed Availability, the Borrower shall deposit with the
     Issuing Bank Cash and Cash Equivalents and/or Additional Collateral in an
     amount sufficient to eliminate such excess and/or cause the Letter of
     Credit Outstandings to be reduced by an amount sufficient to eliminate such
     excess.

<PAGE>

h.   The Letter of Credit Agreement is hereby amended by the addition of
     Schedule 2 attached hereto as "Schedule 2" to the Letter of Credit
     Agreement.

i.   Section 6.01 of the Letter of Credit Agreement is hereby amended in its
     entirety to read as follows:

     "6.01 Liens, Collateral Dispositions. The Company and the Subsidiary Credit
     Parties will not create, incur, assume or permit to exist any Lien on any
     Collateral (as defined in the Pledge and Security Agreement) or, except as
     expressly permitted by the Pledge and Security Agreement, sell, transfer,
     assign or otherwise dispose of any Collateral (as defined in the Pledge and
     Security Agreement); provided that the Company may grant Liens on
     Non-Primary Collateral (as defined in the Pledge and Security Agreement) to
     the Revolving Agent (as defined in the Pledge and Security Agreement), to
     secure the Company's obligations under the Revolving Credit Facility and
     sell, transfer assign or otherwise dispose of Non-Primary Collateral to the
     extent permitted by the Revolving Credit Agreement (as defined in the
     Pledge and Security Agreement) or in connection with the Revolving Agent's
     exercise of its remedies pursuant to the Revolving Credit Agreement."

j.   Section 6 of the Letter of Credit Agreement is hereby amended by the
     addition of a new Section 6.03 reading as follows:

     "6.03 Minimum Availability. The Company shall cause "Borrowing Base
     Availability" (as defined in the Revolving Credit Facility) to be at least
     $25,000,000 at all times."

k.   Section 7.01(j) of the Letter of Credit Agreement is hereby amended in its
     entirety to read as follows:

     "(j) The occurrence of an event of default on the part of the Company or
     any Subsidiary Credit Party under the Revolving Credit Facility or any
     other Material Indebtedness to which the Company or any Subsidiary Credit
     Party is a party or any indenture or other agreement relating to the
     Revolving Credit Facility or any other Material Indebtedness of the Company
     or any Subsidiary Credit Party."

l.   Exhibit A to the Letter of Credit Agreement is hereby amended in its
     entirety to read as set forth in Exhibit A attached hereto.

3.   Conditions to Effectiveness. This Amendment shall not be effective until
     each of the following conditions precedent have been fulfilled to the
     satisfaction of the Issuing Bank:

a.   This Amendment shall have been duly executed and delivered by the Company
     and the Issuing Bank.

<PAGE>

b.   The Company shall have established the Metro Inc. Securities Collateral
     Account with the Issuing Bank and the Issuing Bank shall have a perfected
     first priority security interest in such Metro Inc. Securities Collateral
     Account and all Metro Inc. Securities Collateral on deposit therein.

c.   The Company shall have executed any and all further documents, financing
     statements, agreements and instruments and taken any other action that may
     be required under Applicable Law or which the Issuing Bank may reasonably
     request to grant, preserve, protect or perfect Liens on the Collateral for
     the benefit of the Issuing Bank (including, without limitation, the
     execution and delivery of an amended and restated the Pledge and Security
     Agreement), or the validity or priority of any such Lien, all at the
     expense of the Company.

d.   All action on the part of the Company necessary for the valid execution,
     delivery and performance by the Company of this Amendment shall have been
     duly and effectively taken. The Issuing Bank shall have received from the
     Company true copies of the resolutions authorizing the transactions
     described herein, certified by its secretary or other appropriate officer
     to be true and complete.

e.   The Company shall reimburse the Issuing Bank for all expenses incurred in
     connection with this Amendment, including, without limitation, reasonable
     attorneys' fees, costs and expenses.

f.   The Company shall have paid the Issuing Bank all fees due in connection
     with this Amendment as set forth in the Fee Letter between the Company and
     the Issuing Bank dated September 19, 2006.

g.   No Default or Event of Default shall have occurred and be continuing.

h.   The Company shall have provided such additional instruments, documents, and
     opinions of counsel as the Issuing Bank and their counsel may have
     reasonably requested.

4.   Miscellaneous.

a.   Except as provided herein, all terms and conditions of the Letter of Credit
     Agreement remain in full force and effect. The Company hereby ratifies,
     confirms, and reaffirms all of the representations, warranties and
     covenants therein contained.

b.   This Amendment may be executed in several counterparts and by each party on
     a separate counterpart, each of which when so executed and delivered, each
     shall be an original, and all of which together shall constitute one
     instrument. Delivery of an executed counterpart of a signature page hereto
     by telecopy shall be effective as delivery of a manually executed
     counterpart hereof.

c.   This Amendment expresses the entire understanding of the parties with
     respect to the matters set forth herein and supersedes all prior
     discussions or negotiations hereon. Any determination that any provision of
     this Amendment or any application hereof is invalid, illegal or
     unenforceable in any respect and in any instance shall not effect the
     validity, legality, or enforceability of such provision in any other
     instance, or the validity, legality or enforceability of any other
     provisions of this Amendment.

<PAGE>

     IN WITNESS WHEREOF, the parties hereto have caused this Amendment to be
executed as the date first above written.

                                        BANK OF AMERICA, N.A., as Issuing Bank


                                        By: /s/ Alexis MacElhiney
                                            ------------------------------------
                                        Name: Alexis MacElhiney
                                        Title: Director

<PAGE>

                                        THE GREAT ATLANTIC & PACIFIC TEA
                                        COMPANY, INC.


                                        By: /s/ William J. Moss
                                            ------------------------------------
                                        Name: William J. Moss
                                        Title: Vice President, Treasurer