Exhibit 10.4 FIRST AMENDMENT TO 3-YEAR AND 364-DAY REVOLVING CREDIT AGREEMENTS This FIRST AMENDMENT TO 3-YEAR AND 364-DAY REVOLVING CREDIT AGREEMENTS (this "Amendment") is dated as of June 13, 2002, and is entered into by and among Black Hills Corporation, a South Dakota corporation (the "Borrower"), ABN AMRO Bank N.V. in its capacity as administrative agent for the Banks party to each of the Credit Agreements described below (in such capacity, the "Administrative Agent"), and the Required Banks. WHEREAS, the Administrative Agent, the Banks and the Borrower have entered into that certain 364-Day Credit Agreement (as the same has been amended, extended, modified or restated, the "364-Day Credit Agreement") and that certain 3-Year Credit Agreement (as the same has been amended, extended, modified or restated, the "3-Year Credit Agreement") each dated as of August 28, 2001 and each among the Borrower, the financial institutions from time to time party thereto (each a "Bank," and collectively the "Banks"), U.S. Bank, National Association and The Bank of Nova Scotia, in their capacity as documentation agents for the Banks thereunder (in such capacity, "Documentation Agents"), Union Bank of California, N.A. and Bank of Montreal, in their capacity as syndication agents for the Banks thereunder (in such capacity, "Syndication Agents") and ABN AMRO Bank N.V. in its capacity as Administrative Agent for the Banks thereunder (the 364-Day Credit Agreement and the 3-Year Credit Agreement are each referred to individually as a "Credit Agreement" and collectively as the "Credit Agreements"); WHEREAS, the Borrower has requested that the Credit Agreement be amended to, among other things, eliminate a downgrade of its S&P Rating or Moody's Rating below investment grade as an Event of Default and the Banks are, subject to the terms hereof, willing to so amend the Credit Agreement. NOW THEREFORE, in consideration of the mutual conditions and agreements set forth in the Credit Agreements and this Amendment, and other good and valuable consideration, the receipt and sufficiency of which are hereby acknowledged, the parties hereto hereby agree as follows: 1. Definitions. Capitalized terms used in this Amendment, unless otherwise defined herein, shall have the meaning ascribed to such terms in the Credit Agreements. 2. Amendments. Subject to the conditions set forth below, each Credit Agreement is amended as follows: (a) Section 1.1 of each Credit Agreement is hereby amended by amending and restating the following definition in its entirety: 1 "Material Adverse Effect" means a material adverse effect on (i) the business, financial position or results of operations of Borrower or Borrower and its Subsidiaries taken as a whole, (ii) the ability of Borrower to perform its material obligations under the Credit Documents, (iii) the validity or enforceability of the material obligations of Borrower under any Credit Document, (iv) the rights and remedies of the Banks or the Administrative Agent against Borrower; or (v) the timely payment of the principal of and interest on the Loans or other amounts payable by Borrower hereunder, provided, that a downgrade of Borrower's S&P Rating and/or Moody's Rating shall not, in and of itself, be deemed a "Material Adverse Effect" for purposes of this Agreement. (b) Section 1.1 of each Credit Agreement is hereby amended by amending and restating clause (v) of the definition of "Indebtedness" to be and to read as follows: (v) all Guarantees issued by such Person, provided that Long-Term Guaranties shall not be deemed "Indebtedness" for purposes of calculating Borrower's compliance with the financial covenants set forth in Sections 7.16, 7.17 and 7.18 hereof; (c) Section 8.1 of each Credit Agreement is hereby amended by (i) inserting the word "or" at the end of subsection (k) thereof, (ii) deleting the "; or" appearing at the end of subsection (l) thereof and replacing it with ".", and (iii) deleting subsection (m) thereof in its entirety. (d) Schedule 1 to the 364-Day Credit Agreement is hereby deleted in its entirety and a new Schedule 1 in the form of Schedule 1 (364-Day Credit Agreement) attached to this Amendment is hereby substituted therefor. (e) Schedule 1 to the 3-Year Credit Agreement is hereby deleted in its entirety and a new Schedule 1 in the form of Schedule 1 (3-Year Credit Agreement) attached to this Amendment is hereby substituted therefor. (f) Schedule 1 to Exhibit B of each Credit Agreement is hereby amended by changing the words "must not be less than" appearing in Section G(7) of each such schedule to "not to exceed". 3. Ratification. The Borrower hereby ratifies, acknowledges, affirms and reconfirms its rights, interests and obligations under each Credit Document and agrees to perform each of its obligations thereunder as and when required. By executing this Amendment, the Borrower hereby further ratifies, acknowledges, affirms and reconfirms that each Credit Document, as amended hereby, constitutes a legal, valid and binding obligation of the Borrower enforceable against the Borrower in accordance with its terms, and that each such Credit Document, as amended hereby, is in full force and effect. 2 4. Conditions. The effectiveness of this Amendment is subject to the following conditions precedent (unless specifically waived in writing by the Administrative Agent): (a) The Borrower and the Required Banks shall have executed and delivered this Amendment, and the Borrower shall have executed and/or delivered such other documents and instruments as Administrative Agent may require. (b) The representations and warranties set forth in Section 5 of this Amendment shall be true and correct. (c) All proceedings taken in connection with the transactions contemplated by this Amendment and all documents, instruments and other legal matters incident thereto shall be reasonably satisfactory to Administrative Agent and its legal counsel. 5. Representations and Warranties. To induce the Administrative Agent and the Banks to enter into this Amendment, the Borrower represents and warrants to the Administrative Agent and the Banks that (i) the execution, delivery and performance of this Amendment has been duly authorized by all requisite corporate action on the part of the Borrower and that this Amendment has been duly executed and delivered by the Borrower and this Amendment and the Credit Agreements, as amended hereby, constitute valid and binding obligations of the Borrower enforceable in accordance with their respective terms, (ii) no Default or Event of Default (after giving effect to this Amendment) has occurred and is continuing under the Credit Agreements or would result from the execution and delivery of this Amendment, and (iii) each of the representations and warranties set forth in Section 5 of the Credit Agreements, as amended hereby, is true and correct in all material respects as of the date hereof, except that if any such representation or warranty relates solely to an earlier date it need only remain true as of such date. 6. Severability. Any provision of this Amendment held by a court of competent jurisdiction to be invalid or unenforceable shall not impair or invalidate the remainder of this Amendment and the effect thereof shall be confined to the provision so held to be invalid or unenforceable. 7. References. Any reference to the Credit Agreements contained in any document, instrument or agreement executed in connection with the Credit Agreements shall be deemed to be a reference to the Credit Agreements as modified by this Amendment. 8. Counterparts. This Amendment may be executed in one or more counterparts, each of which shall constitute an original, but all of which taken together shall be one and the same instrument. This Amendment may also be executed by facsimile and each facsimile signature hereto shall be deemed for all purposes to be an original signatory page. 3 9. Costs. The Borrower agrees to pay on demand all reasonable costs and expenses incurred by the Administrative Agent (including fees and expenses of counsel) incurred in connection with the negotiation and preparation of this Amendment. 10. Governing Law. The validity and interpretation of this Amendment and the terms and conditions set forth herein, shall be governed by and construed in accordance with the laws of the State of New York, without giving effect to any provisions relating to conflict of laws other than section 5-1401 of the New York General Obligations Laws. 11. Miscellaneous. This Amendment shall be deemed to be a Credit Document. [- Remainder of Page Left Blank - Signature Pages Follow -] 4 In Witness Whereof, the parties hereto have caused this Agreement to be duly executed and delivered in New York, New York by their duly authorized officers as of the day and year first above written. BLACK HILLS CORPORATION, a South Dakota corporation By: _____________________________ Name: _____________________________ Title: _____________________________ 5 ABN AMRO BANK N.V., in its individual capacity as a Bank and as Administrative Agent By: _____________________________ Name: David B. Bryant Title: Senior Vice President & Managing Director By: _____________________________ Name: _____________________________ Title: _____________________________ 6 UNION BANK OF CALIFORNIA, N.A. By: _____________________________ Name: Robert J. Cole Title: Vice President 7 U.S. BANK, NATIONAL ASSOCIATION, in its individual capacity as a Bank and as Documentation Agent By: _____________________________ Name: Sandra Vollmer Title: Senior Lender 8 BANK OF MONTREAL By: _____________________________ Name: Ian M. Plester Title: Director 9 THE BANK OF NOVA SCOTIA By: _____________________________ Name: F.C.H. Ashby Title: Senior Manager Loan Operations 10 CIBC INC., as a Lender By: _____________________________ Name: M. Sanjeeva Senanayake Title: Executive Director CIBC World Markets Corp. As Agent 11 COBANK, ACB By: _____________________________ Name: Cathleen Reed Title: Assistant Vice President 12 WELLS FARGO BANK, N.A. By: _____________________________ Name: Thomas M. Foncannon Title: Senior Vice President 13 MIZUHO CORPORATE BANK, LTD. By: _____________________________ Name: Nobuyasu Fukatsu Title: Senior Vice President 14 NATIONAL CITY BANK OF MICHIGAN/ILLINOIS By: _____________________________ Name: Mark R. Long Title: Senior Vice President 15 NORDEUTSCHE LANDESBANK GIROZENTRALE NEW YORK/ CAYMAN ISLANDS BRANCH By: _____________________________ Name: Stephanie Finnen Title: Vice President By: _____________________________ Name: Joseph Haas Title: Vice President 16 CHANG HWA BANK, LOS ANGELES BRANCH By: _____________________________ Name: James Lin Title: Senior Vice President and General Manager 17 SCHEDULE 1 (364-Day Credit Agreement) PRICING GRID - ------------------ ------------------- ------------ ------------------- ------------------- If the Level Subject to the The Subject to the Subject to the Status Is proviso below Utilization proviso below proviso below this grid, the Fee Rate this grid, the this grid, the Facility Fee Rate is: Eurodollar Margin Base Rate Margin is: is: is: - ------------------ ------------------- ------------ ------------------- ------------------- - ------------------ ------------------- ------------ ------------------- ------------------- Level I Status 0.080% 0.100% 0.420% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------- - ------------------ ------------------- ------------ ------------------- ------------------- Level II Status 0.100% 0.125% 0.500% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------- - ------------------ ------------------- ------------ ------------------- ------------------- Level III Status 0.125% 0.125% 0.625% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------- Level IV Status 0.150% 0.125% 0.725% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------- - ------------------ ------------------- ------------ ------------------- ------------------- Level V Status 0.200% 0.250% 0.800% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------- - ------------------ ------------------- ------------ ------------------- ------------------- Level VI Status 0.600% 0.500% 1.400% 0.475% - ------------------ ------------------- ------------ ------------------- ------------------- Each change in a rating shall be effective as of the date it is announced by the applicable rating agency. Until the Borrower receives an S&P Rating, the applicable Level shall be determined based upon the Borrower's Moody's Rating. In the event that the Moody's Rating and the S&P Rating fall in consecutive Levels, the rating falling in the lower Level (with Level I being the highest Level and Level VI being the lowest Level) shall govern for purposes of determining the applicable pricing pursuant to the above pricing grid. In the event that the Moody's Rating and the S&P Rating fall in non-consecutive Levels, the Level immediately above the Level in which the lower rating falls (with Level I being the highest Level and Level VI being the lowest Level) shall govern for purposes of determining the applicable pricing pursuant to the above pricing grid. 18 SCHEDULE 1 (3-Year Credit Agreement) PRICING GRID - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- If the Level Subject to the The Subject to the Subject to the Subject to the Status Is proviso below Utilization proviso below proviso below proviso below this this grid, the Fee Rate this grid, the this grid, the grid, the Base Facility Fee Rate is: L/C Fee Rate is: Eurodollar Rate Margin is: is: Margin is: - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level I Status 0.100% 0.100% 0.400% 0.400% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level II Status 0.125% 0.125% 0.475% 0.475% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level III Status 0.150% 0.125% 0.600% 0.600% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level IV Status 0.175% 0.125% 0700% 0.700% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level V Status 0.250% 0.250% 0.750% 0.750% 0.000% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Level VI Status 0.500% 0.500% 1.500% 1.500% 0.500% - ------------------ ------------------- ------------ ------------------- ------------------ -------------------- Each change in a rating shall be effective as of the date it is announced by the applicable rating agency. Until the Borrower receives an S&P Rating, the applicable Level shall be determined based upon the Borrower's Moody's Rating. In the event that the Moody's Rating and the S&P Rating fall in consecutive Levels, the rating falling in the lower Level (with Level I being the highest Level and Level VI being the lowest Level) shall govern for purposes of determining the applicable pricing pursuant to the above pricing grid. In the event that the Moody's Rating and the S&P Rating fall in non-consecutive Levels, the Level immediately above the Level in which the lower rating falls (with Level I being the highest Level and Level VI being the lowest Level) shall govern for purposes of determining the applicable pricing pursuant to the above pricing grid.