QuickLinks -- Click here to rapidly navigate through this document


Exhibit 5.1

[LETTERHEAD OF BALLARD SPAHR ANDREWS & INGERSOLL, LLP]

June 15, 2007

St. Mary Land & Exploration Company
1776 Lincoln Street, Suite 700
Denver, Colorado 80203

Ladies and Gentlemen:

        We have acted as counsel to St. Mary Land & Exploration Company, a Delaware corporation (the "Company"), and are rendering this opinion in connection with the filing of a Registration Statement on Form S-3 (the "Registration Statement") by the Company with the Securities and Exchange Commission under the Securities Act of 1933, as amended (the "Securities Act"), relating to the registration by the Company of the resale by the selling securityholders listed in the Registration Statement of up to (i) $287,500,000 aggregate principal amount of the Company's 3.50% Senior Convertible Notes due 2027 (the "Notes") issued under an Indenture dated as of April 4, 2007 (the "Indenture") between the Company and Wells Fargo Bank, National Association (the "Trustee"), which Indenture by the terms thereof is governed by the laws of the State of New York, and (ii) 5,283,014 shares of the Company's common stock, par value $0.01 per share, issuable upon conversion of the Notes (the "Conversion Shares").

        The Notes were initially sold by the Company in reliance on Section 4(2) of the Securities Act and may be resold or delivered from time to time as set forth in the Registration Statement, any amendment thereto and the prospectus contained therein pursuant to Rule 415 under the Securities Act.

        In our capacity as counsel, we have examined the Registration Statement, and the Indenture, a copy of the Note originally issued under the Indenture on April 4, 2007, and a form of certificate for common stock of the Company, which have been filed as exhibits to the Registration Statement. We have also examined originals or copies, certified or otherwise identified to our satisfaction, of such agreements, documents, instruments, and corporate records, and such certificates or comparable documents of public officials and officers and representatives of the Company, and have made such inquiries of such officers and representatives and have considered such matters of law as we have deemed appropriate as the basis for the opinions hereinafter set forth. In giving this opinion, we have assumed the authenticity of all documents presented to us as originals, the conformity with the originals of all documents presented to us as copies and the genuineness of all signatures. In making our examination of documents executed by parties other than the Company, we have assumed that such parties had the power (including, without limitation, corporate power where applicable) and authority to enter into and perform all obligations thereunder, the due authorization, execution and delivery by such parties of each such document, and that such documents constitute legal, valid and binding obligations of each such party, enforceable against each such party in accordance with their respective terms, including that the Indenture is a legal, valid and binding obligation of the Trustee. We have also assumed that the Conversion Shares will continue to be duly and validly authorized on the dates that the Conversion Shares are issued upon conversion of the Notes in accordance with the terms of the Indenture, and, upon the issuance of any of the Conversion Shares, the total number of shares of common stock of the Company issued and outstanding, after giving effect to such issuance of such Conversion Shares, will not exceed the total number of shares of common stock that the Company is then authorized to issue under its certificate of incorporation.



        Based upon and subject to the limitations, qualifications and assumptions set forth herein, we are of the opinion that:

        Our opinion set forth in paragraph 1 above is subject to the effect of applicable bankruptcy, insolvency, reorganization, moratorium, fraudulent conveyance, fraudulent transfer, marshalling or similar laws affecting creditors' rights and remedies generally, and general principles of equity, including without limitation, concepts of materiality, reasonableness, good faith and fair dealing (regardless of whether considered in a proceeding in equity or at law).

        We express no opinion as to the laws of any jurisdiction other than the General Corporation Law of the State of Delaware and the laws of the State of New York.

        This opinion is limited to the matters expressly stated herein. No implied opinion may be inferred to extend this opinion beyond the matters expressly stated herein. We do not undertake to advise you of any changes in the opinion expressed herein resulting from changes in law, changes in facts or any other matters that might occur or be brought to our attention after the date hereof.

        We hereby consent to the sole use of this opinion as an exhibit to the Registration Statement and to the use of our name under the heading "Legal Matters" in the prospectus included therein. This opinion is not to be used, circulated, quoted, referred to or relied upon by any other person or for any other purpose without our prior written consent.

    Very truly yours,

 

 

/s/ Ballard Spahr Andrews & Ingersoll, LLP

2




QuickLinks