1 Exhibit 5.1 BALLARD SPAHR ANDREWS & INGERSOLL January 30, 1998 Getty Realty Holding Corp. 125 Jericho Turnpike Jericho, New York 11753 Re: Registration Statement on Form S-8: Getty Realty Corp. Retirement (401(k)) and Profit Sharing Plan (the "Plan") Ladies and Gentlemen: We have served as Maryland counsel to Getty Realty Holding Corp., a Maryland corporation (the "Company"), in connection with its filing with the Securities and Exchange Commission (the "Commission") of a Registration Statement on Form S-8 (the "Registration Statement") relating to 50,000 shares (the "Shares") of Common Stock, $.01 par value per share, of the Company (the "Common Stock") to be offered or sold by the Company to participants of the Plan. Capitalized terms used but not defined herein shall have the meanings given to them in the Registration Statement. In connection with our representation of the Company, and as a basis for the opinions hereinafter set forth, we have examined originals, or copies certified or otherwise identified to our satisfaction, of the following documents (hereinafter collectively referred to as the "Documents"): 1. The Registration Statement; 2. The charter of the Company (the "Charter"), certified as of a recent date by the State Department of Assessments and Taxation of Maryland (the "SDAT"); 3. The Bylaws of the Company (the "Bylaws"), certified as of a recent date by its Corporate Secretary; 4. A certificate as of a recent date of the SDAT as to the good standing of the Company; 5. Resolutions adopted by the Board of Directors of the Company relating to the sale, issuance and registration of the Shares (the "Resolutions"), certified as of a recent date by the Corporate Secretary of the Company; 6. A form of certificate representing the Shares, certified as of a recent date by the Corporate Secretary of the Company. 7. A certificate executed by Randi Young Filip, Corporate Secretary of the Company, dated as of a recent date; and 8. Such other documents and matters as we have deemed necessary or appropriate to express the opinion set forth in this letter, subject to the assumptions, limitations and qualifications stated herein. In expressing the opinions set forth below, we have assumed, and so far as is known to us there are no facts inconsistent with, the following: 1. Each of the parties (other than the Company) executing any of the Documents has duly and validly executed and delivered each of the Documents to which such party is a signatory, and such party's obligations set forth therein are legal, valid and binding and are enforceable in accordance with all stated terms. 2. Each individual executing any of the Documents on behalf of a party (other than the Company) is duly authorized to do so. 3. Each individual executing any of the Documents, whether on behalf of such individual or another person, is legally competent to do so. 4. All Documents submitted to us as originals are authentic. All Documents submitted to us as certified or photostatic copies conform to the original documents. All signatures on all Documents are genuine. All public records reviewed or relied upon by us or on our behalf are true and complete. All statements and information contained in the Documents are true and complete. There are no modifications of or amendments to the Documents, and there has been no waiver of any of the provisions of the Documents, by action or omission of the parties or otherwise. 2 The phrase "known to us" is limited to the actual knowledge, without independent inquiry, of the lawyers at our firm who have performed legal services in connection with the issuance of this opinion for the Company. Based upon the foregoing, and subject to the assumptions, limitations and qualifications stated herein, it is our opinion that: 1. The Company is a corporation duly incorporated and validly existing under the laws of the State of Maryland and is in good standing with the SDAT. 2. The Shares have been duly authorized and, when and if delivered against payment therefor in accordance with the Plan and the resolutions of the Board of Directors of the Company authorizing their issuance, will be (assuming that the sum of (i) all shares of Common Stock issued and outstanding on the date hereof, (ii) all shares of Common Stock issued between the date hereof and the date on which the Shares are issued (not including the Shares) and (iii) the Shares will not exceed the number of shares of Common Stock that the Company then has authority to issue) validly issued, fully paid and nonassessable. The foregoing opinion is limited to the substantive laws of the State of Maryland and we do not express any opinion herein concerning any other law. We express no opinion as to the applicability or effect of any state or federal securities laws, including the securities laws of the State of Maryland, or as to federal or state laws regarding fraudulent transfers. To the extent that any matter as to which our opinion is expressed herein would be governed by any jurisdiction other than the State of Maryland, we do not express any opinion on such matter. The opinion expressed herein is subject to the effect of judicial decisions which may permit the introduction of parol evidence to modify the terms or the interpretation of agreements. We assume no obligation to supplement this opinion if any applicable law changes after the date hereof or if we become aware of any fact that might change the opinion expressed herein after the date hereof. This opinion is being furnished to you solely for submission to the Commission as an exhibit to the Registration Statement and, accordingly, may not be relied upon by, quoted in any manner to, or delivered to any other person or entity without, in each instance, our prior written consent. We hereby consent to the filing of this opinion as an exhibit to the Registration Statement and to the use of the name of our firm therein. In giving this consent, we do not admit that we are within the category of persons whose consent is required by Section 7 of the Securities Act of 1933, as amended. Very truly yours, /s/ Ballard Spahr Andrews & Ingersoll