EXHIBIT 5.1 August 18, 1999 St. Mary Land & Exploration Company 1776 Lincoln Street, Suite 1100 Denver, Colorado 80203 Re: Common Stock of St. Mary Land & Exploration Company, a Delaware Corporation ("St. Mary"), to be Issued Under the Agreement and Plan of Merger dated July 27, 1999 Gentlemen: We have acted as your counsel in connection with the proposed issuance of shares of common stock under the Agreement and Plan of Merger dated July 27, 1999 (the "Merger Agreement") whereby a wholly owned subsidiary of St. Mary will be merged with and into King Ranch Energy, Inc., a Delaware corporation ("King Ranch Energy"), and King Ranch Energy will become a wholly owned subsidiary of St. Mary, as more fully described in the related Registration Statement on Form S-4 (the "Registration Statement") to be filed with the Securities and Exchange Commission under the Securities Act of 1933, as amended. In that connection, we have examined originals and copies, certified or otherwise identified to our satisfaction, of such documents, corporate records and other instruments as we have deemed necessary for the purposes of the opinion expressed below, including but not limited to the Merger Agreement. Based upon the foregoing, we are of the opinion that the shares of common stock to be issued by St. Mary under the Merger Agreement have been duly authorized and, when duly executed, delivered and when issued in accordance with the terms of the Merger Agreement and upon effectiveness of the Registration Statement, and upon satisfaction of all applicable conditions, will be duly and validly issued, fully paid and nonassessable. We express no opinion concerning the laws of any jurisdiction other than the laws of the United States and the laws of the State of Delaware. We hereby consent to the filing of this opinion as an exhibit to the Registration Statement and to the reference to this firm under the caption "Legal Matters" in the joint proxy/consent statement and prospectus included in the Registration Statement. Very truly yours, /S/ BALLARD SPAHR ANDREWS & INGERSOLL, LLP