Exhibit 10.4

Execution Version

FOURTH AMENDMENT

TO

CREDIT AGREEMENT

AMONG

REX ENERGY CORPORATION,

as Borrower,

KEYBANK NATIONAL ASSOCIATION,

as Administrative Agent,

and

The Lenders Signatory Hereto

Effective as of December 18, 2009

--------------------------------------------------------------------------------

FOURTH AMENDMENT TO CREDIT AGREEMENT

This FOURTH AMENDMENT TO CREDIT AGREEMENT (this “Fourth Amendment”) executed
effective as of the 18th of December, 2009 (the “Fourth Amendment Effective
Date”) is among REX ENERGY CORPORATION, a corporation formed under the laws of
the State of Delaware (the “Borrower”); KEYBANK NATIONAL ASSOCIATION, as
administrative agent for the Lenders (in such capacity, together with its
successors, the “Administrative Agent”), and the Lenders signatory hereto.

Recitals

A. The Borrower, the Administrative Agent and the Lenders are parties to that
certain Credit Agreement dated as of September 28, 2007, as amended by that
certain First Amendment dated as of April 14, 2008, as amended by that certain
Second Amendment dated as of December 23, 2008, as amended by that certain Third
Amendment dated as of April 20, 2009 (the “Credit Agreement”), pursuant to which
the Lenders have made certain credit available to and on behalf of the Borrower.

B. The Borrower has informed the Administrative Agent that it formed R.E. Gas
Development, LLC, a Delaware limited liability company and wholly owned
Subsidiary of the Borrower (“R.E. Gas”), and inadvertently failed to inform the
Administrative Agent that it was forming R.E. Gas and cause R.E. Gas to become a
Guarantor in accordance with the requirements of Sections 9.15 and 8.14(b),
respectively, of the Credit Agreement (the “Non-Compliance Event”).

C. The Borrower has requested that the Administrative Agent and the Lenders
waive the Non-Compliance Event, and the Administrative Agent and the Lenders
have agreed to waive the Non-Compliance Event subject to the terms and
conditions of this Fourth Amendment.

D. The Borrower, the Administrative Agent and the Lenders have agreed to amend
certain provisions of the Credit Agreement to permit an investment by R.E. Gas
in a joint venture, in an amount in excess of the amount permitted by
Section 9.05 of the Credit Agreement.

E. NOW, THEREFORE, in consideration of the premises and the mutual covenants
herein contained, for good and valuable consideration, the receipt and
sufficiency of which are hereby acknowledged, the parties hereto agree as
follows:

Section 1. Defined Terms. Each capitalized term which is defined in the Credit
Agreement, but which is not defined in this Fourth Amendment, shall have the
meaning ascribed such term in the Credit Agreement. Unless otherwise indicated,
all section references in this Fourth Amendment refer to the Credit Agreement.

Section 2. Amendments to Credit Agreement.

2.1 Amendments to Section 1.02. Section 1.02 is hereby amended by adding the
following definitions in the appropriate alphabetical order:

“‘Keystone’ means Keystone Midstream Services, LLC, a Delaware limited liability
company.

 

Page 2

--------------------------------------------------------------------------------

‘R.E. Gas’ means R.E. Gas Development, a Delaware limited liability company.”

2.2 Amendment to Section 9.05. Section 9.05 is hereby amended by adding the
following sub-section (r):

“(r) Investment by R.E. Gas in Keystone in an amount not to exceed $10,000,000
in cash and $1,800,000 in Property.”

Section 3 Limited Waiver. In reliance on the representations and warranties set
forth in Section 5 below and subject to the satisfaction of the conditions set
forth in Section 4 below, the Administrative Agent and the Lenders hereby waive
the Non-Compliance Event.

Section 4. Conditions Precedent. The effectiveness of this Fourth Amendment is
subject to the receipt by the Administrative Agent of the following documents
and satisfaction of the other conditions provided in this Section 4, each of
which shall be reasonably satisfactory to the Administrative Agent in form and
substance:

4.1 Fourth Amendment. The Administrative Agent shall have received multiple
counterparts as requested of this Fourth Amendment from the Borrower and each
Lender.

4.2 Assumption Agreement and Supplement. The Administrative Agent shall have
received multiple counterparts of the Assumption Agreement to the Guaranty
Agreement in the form of Annex II thereto executed by R.E. Gas and the
Supplement to the Guarantee Agreement in the form of Annex III thereto executed
by the Borrower.

4.3 Payment of Outstanding Invoices. Payment by the Borrower to the
Administrative Agent of all fees and other amounts due and payable on or prior
to the Fourth Amendment Effective Date, including, to the extent invoiced,
reimbursement or payment of all out-of-pocket expenses required to be reimbursed
or paid by the Borrower (including, but not limited to the fees of Vinson &
Elkins L.L.P.).

4.4 No Default. No Default or Event of Default other than the Non-Compliance
Event shall have occurred and be continuing as of the Fourth Amendment Effective
Date.

Section 5. Representations and Warranties; Etc. The Borrower hereby affirms:
(a) that as of the date of execution and delivery of this Fourth Amendment, all
of the representations and warranties contained in each Loan Document to which
the Borrower is a party are true and correct in all material respects as though
made on and as of the Fourth Amendment Effective Date (unless made as of a
specific earlier date, in which case, was true as of such date); and (b) that
after giving effect to this Fourth Amendment and to the transactions
contemplated hereby, no Defaults exist under the Loan Documents or will exist
under the Loan Documents.

 

Page 3

--------------------------------------------------------------------------------

Section 6. Miscellaneous.

6.1 Confirmation. The provisions of the Credit Agreement (as amended by this
Fourth Amendment) shall remain in full force and effect in accordance with its
terms following the effectiveness of this Fourth Amendment.

6.2 Ratification and Affirmation of the Borrower. The Borrower hereby expressly
(a) acknowledges the terms of this Fourth Amendment, (b) ratifies and affirms
its obligations under the Credit Agreement and the other Security Instruments to
which it is a party, and (c) acknowledges, renews and extends its continued
liability under the Credit Agreement and the other Security Instruments to which
it is a party remains in full force and effect with respect to the Indebtedness
as amended hereby.

6.3 Counterparts. This Fourth Amendment may be executed by one or more of the
parties hereto in any number of separate counterparts, and all of such
counterparts taken together shall be deemed to constitute one and the same
instrument.

6.4 Limited Waiver. Neither the execution by the Administrative Agent or the
Lenders of this Fourth Amendment, nor any other act or omission by the
Administrative Agent or the Lenders or their officers in connection herewith,
shall be deemed a waiver by the Administrative Agent or the Lenders of any
defaults which may exist (other than the Non-Compliance Event as waived herein),
or which may occur in the future under the Credit Agreement and/or the other
Loan Documents, or any future defaults of the same provision waived hereunder
(collectively “Other Violations”). Similarly, nothing contained in this Fourth
Amendment shall directly or indirectly in any way whatsoever either: (a) impair,
prejudice or otherwise adversely affect the Administrative Agent’s or the
Lenders’ right at any time to exercise any right, privilege or remedy in
connection with the Loan Documents with respect to any Other Violations,
(b) amend or alter any provision of the Credit Agreement (except as specifically
amended herein), the other Loan Documents, or any other contract or instrument,
or (c) constitute any course of dealing or other basis for altering any
obligation of the Borrower or any right, privilege or remedy of the
Administrative Agent or the Lenders under the Credit Agreement, the other Loan
Documents, or any other contract or instrument. Nothing in this Fourth Amendment
shall be construed to be a consent by the Administrative Agent or the Lenders to
any Other Violations.

6.5 No Oral Agreement. THIS WRITTEN FOURTH AMENDMENT, THE CREDIT AGREEMENT AND
THE OTHER LOAN DOCUMENTS EXECUTED IN CONNECTION HEREWITH AND THEREWITH REPRESENT
THE FINAL AGREEMENT BETWEEN THE PARTIES AND MAY NOT BE CONTRADICTED BY EVIDENCE
OF PRIOR, CONTEMPORANEOUS, OR UNWRITTEN ORAL AGREEMENTS OF THE PARTIES. THERE
ARE NO SUBSEQUENT ORAL AGREEMENTS BETWEEN THE PARTIES.

6.6 Governing Law. THIS FOURTH AMENDMENT (INCLUDING, BUT NOT LIMITED TO, THE
VALIDITY AND ENFORCEABILITY HEREOF) SHALL BE GOVERNED BY, AND CONSTRUED IN
ACCORDANCE WITH, THE LAWS OF THE STATE OF TEXAS.

6.7 Release of Lenders. IN CONSIDERATION OF THIS FOURTH AMENDMENT AND, SUBJECT
TO THE CONDITIONS STATED HEREIN, THE

 

Page 4

--------------------------------------------------------------------------------

BORROWER HEREBY RELEASES, ACQUITS, FOREVER DISCHARGES, AND COVENANTS NOT TO SUE,
THE ADMINISTRATIVE AGENT AND EACH OF THE LENDERS, ALONG WITH ALL OF THEIR
BENEFICIARIES, OFFICERS, DIRECTORS, AGENTS, EMPLOYEES, SERVANTS, ATTORNEYS AND
REPRESENTATIVES, AS WELL AS THEIR RESPECTIVE HEIRS, EXECUTORS, LEGAL
REPRESENTATIVES, ADMINISTRATORS, PREDECESSORS IN INTEREST, SUCCESSORS AND
ASSIGNS (EACH INDIVIDUALLY, A “RELEASED PARTY” AND COLLECTIVELY, THE “RELEASED
PARTIES”) FROM ANY AND ALL CLAIMS, DEMANDS, DEBTS, LIABILITIES, SUITS, OFFSETS
AGAINST THE INDEBTEDNESS EVIDENCED BY THE LOAN DOCUMENTS AND ACTIONS, CAUSES OF
ACTION OR CLAIMS FOR RELIEF OF WHATEVER KIND OR NATURE, WHETHER KNOWN OR
UNKNOWN, SUSPECTED OR UNSUSPECTED BY BORROWER OR ANY OBLIGOR, WHICH BORROWER,
ANY OBLIGOR, OR ANY SUBSIDIARY MAY HAVE OR WHICH MAY HEREAFTER ACCRUE RELATED TO
ANY ACTIONS OR FACTS OCCURRING PRIOR TO THE FOURTH AMENDMENT EFFECTIVE DATE
AGAINST ANY RELEASED PARTY, FOR OR BY REASON OF ANY MATTER, CAUSE OR THING
WHATSOEVER OCCURRING ON OR PRIOR TO THE FOURTH AMENDMENT EFFECTIVE DATE, WHICH
RELATE TO, IN WHOLE OR IN PART, DIRECTLY OR INDIRECTLY THE CREDIT AGREEMENT, ANY
HEDGING AGREEMENT, ANY NOTE, ANY SECURITY INSTRUMENT, ANY OTHER LOAN DOCUMENT OR
THE TRANSACTIONS EVIDENCED THEREBY, INCLUDING, WITHOUT LIMITATION, ANY
DISBURSEMENTS UNDER THE CREDIT AGREEMENT, ANY HEDGING AGREEMENT, ANY NOTES, THE
NEGOTIATION OF ANY OF THE CREDIT AGREEMENT, THE SWAP AGREEMENTS, THE NOTES, OR
THE OTHER LOAN DOCUMENTS, THE TERMS THEREOF, OR THE APPROVAL, ADMINISTRATION,
ENFORCEMENT OR SERVICING THEREOF.

 

Page 5

--------------------------------------------------------------------------------

IN WITNESS WHEREOF, the parties hereto have caused this Fourth Amendment to be
duly executed effective as of the Fourth Amendment Effective Date.

BORROWER:

 

REX ENERGY CORPORATION By:  

/s/ Benjamin W. Hulburt

Name:   Benjamin W. Hulburt Title:   President and Chief Executive Officer

ADMINISTRATIVE AGENT:

 

KEYBANK NATIONAL ASSOCIATION,

as Administrative Agent and Lender

By:  

/s/ Todd Coker

Name:   Todd Coker Title:   Assistant Vice President

--------------------------------------------------------------------------------

LENDERS:

 

BNP PARIBAS By:  

/s/ Betsy Jocher

Name:   Betsy Jocher Title:   Director By:  

/s/ Edward Pak

Name:   Edward Pak Title:   Vice President

--------------------------------------------------------------------------------

ALLIED IRISH BANK By:  

/s/ David O’Driscoll

Name:   David O’Driscoll Title:   Assistant Vice President By:  

/s/ Vaughn Buck

Name:   Vaughn Buck Title:   Executive Vice President

--------------------------------------------------------------------------------

M&T BANK By:  

/s/ David Ladori

Name:   David Ladori Title:   Vice President

--------------------------------------------------------------------------------

CAPITAL ONE, N.A. By:  

/s/ James McBride

Name:   James McBride Title:   Executive Vice President