
<PAGE>
 
                                                                     EXHIBIT 5.1


                               February 11, 1998



Kilroy Realty Corporation
2250 East Imperial Highway
El Segundo, California  90245

     Re:  Kilroy Realty Corporation (the "Company") Amendment No. 1 to
          Registration Statement on Form S-3 pertaining to $400,000,000 maximum
          aggregate initial offering price of (i) shares of common stock of the
          Company, par value $.01 per share ("Common Stock"); (ii) shares of
          preferred stock of the Company, par value $.01 per share ("Preferred
          Stock"); and (iii) warrants to purchase shares of Common Stock or
          shares of Preferred Stock ("Warrants")
          --------------------------------------------------------------------

Ladies and Gentlemen:

     In connection with the registration of shares of Common Stock, shares of
Preferred Stock and Warrants (collectively, the "Securities") under the
Securities Act of 1933, as amended (the "Act"), by the Company on Form S-3,
filed with the Securities and Exchange Commission (the "Commission") on January
28, 1998 (the "Registration Statement") and Amendment No. 1 to the Registration
Statement filed or to be filed with the Commission on or about February 11,
1998, you have requested our opinion with respect to the matters set forth
below. Capitalized terms not otherwise defined herein shall have the meanings
ascribed to them in the Registration Statement.

     We have acted as special Maryland corporate counsel to the Company in
connection with the matters described herein.  In our capacity as special
Maryland corporate counsel to the Company, we have reviewed and are familiar
with the charter of the Company (the "Charter"), consisting of Articles of
Incorporation filed with the Maryland State Department of Assessments and
Taxation (the "Department") on September 13, 1996 and Articles of Amendment and
Restatement filed with the Department on January 21, 1997; the Amended and
Restated Bylaws of the Company (the "Bylaws"), which were duly adopted by the
Board of Directors of the Company on January 26, 1997; and certain resolutions
adopted and actions taken by the Board of Directors of the Company (the "Board
of Directors")
<PAGE>
 
BALLARD SPAHR ANDREWS & INGERSOLL
 
Kilroy Realty Corporation
February 11, 1998
Page 2


on or before the date hereof and in full force and effect on the date hereof
including, but not limited to, those certain resolutions adopted by the Board of
Directors on December 16, 1997.  We have also examined the Registration
Statement, other documents, corporate and other records of the Company and
certificates of public officials and officers of the Company including, without
limitation, a status certificate of recent date issued by the Department to the
effect that the Company is duly incorporated and existing under the laws of the
State of Maryland, and a Certificate of Officers of the Company of recent date
to the effect that, among other things, the Charter and Bylaws of the Company
and the resolutions and actions by the Board of Directors which we have examined
are true, correct and complete, have not been rescinded or modified and are in
full force and effect on the date of such certificate.  We have also made such
further legal and factual examinations as we have deemed necessary or
appropriate to provide a basis for the opinion set forth below.

     In reaching the opinions set forth below, we have assumed the following:
(a) each person executing any instrument, document or agreement on behalf of any
party (other than the Company) is duly authorized to do so; (b) each natural
person executing any instrument, document or agreement is legally competent to
do so; (c) all documents submitted to us as originals are authentic; all
documents submitted to us as certified, facsimile or photostatic copies conform
to the original document; all signatures on all documents submitted to us for
examination are genuine; and all public records reviewed are accurate and
complete; (d) the resolutions adopted and to be adopted, and the actions taken
and to be taken by the Board of Directors including, but not limited to, the
adoption of all resolutions and the taking of all action necessary to authorize
the issuance and sale of the Securities in accordance with the procedures set
forth in paragraphs 1, 2 and 3 below, have occurred or will occur at duly called
meetings at which a quorum of the incumbent directors of the Company were or are
present and acting throughout, or by unanimous written consent of all incumbent
directors, all in accordance with the Charter and Bylaws of the Company and
applicable law; (e) the number of shares of Preferred Stock and the number of
shares of Common Stock to be offered and sold under the Registration Statement,
together with the number of shares of Preferred Stock and the number of shares
of Common Stock issuable upon exercise of the Warrants, will not, in the
aggregate, exceed the number of shares of Preferred Stock, and the number of
shares of Common Stock, respectively, authorized in the Charter of the Company,
less the number of shares of Preferred 
<PAGE>
 
BALLARD SPAHR ANDREWS & INGERSOLL
 
Kilroy Realty Corporation
February 11, 1998
Page 3


Stock and the number of shares of Common Stock, respectively, authorized and
reserved for issuance and issued and outstanding on the date on which the
Securities are authorized, the date on which the Securities are issued and
delivered, the date on which the Warrants are exercised and the date on which
shares of Preferred Stock and shares of Common Stock, respectively, are issued
pursuant to exercise of Warrants; (f) none of the terms of any Security to be
established subsequent to the date hereof, nor the issuance and delivery of such
Security nor the compliance by the Company with the terms of such Security will
violate any applicable law or will conflict with, or result in a breach or
violation of, the Charter or Bylaws of the Company, or any instrument or
agreement to which the Company is a party or by which the Company is bound or
any order or decree of any court, administrative or governmental body having
jurisdiction over the Company; and (g) none of the Securities, and none of the
shares of Preferred Stock or shares of Common Stock issuable upon exercise of
the Warrants, will be issued and sold to an Interested Stockholder of the
Company or an Affiliate thereof, all as defined in Subtitle 6 of Title 3 of the
Maryland General Corporation Law, or in violation of the provisions of Article
IV, Section E of the Charter of the Company entitled "Restrictions on Ownership
and Transfer to Preserve Tax Benefits."

     Based on the foregoing, and subject to the assumptions and qualifications
set forth herein, it is our opinion that:

     1.   Upon due authorization by the Board of Directors of a designated
number of shares of Common Stock for issuance at a minimum price or value of
consideration to be set by the Board of Directors, all necessary corporate
action on the part of the Company will have been taken to authorize the issuance
and sale of such shares of Common Stock, and when such Common Shares are issued
and delivered against payment of the consideration therefor as set by the Board
of Directors, such shares of Common Stock will be validly issued, fully paid and
non-assessable.

     2.   Upon:  (a) designation by the Board of Directors of one or more
classes of Preferred Stock to distinguish each such class from other than
outstanding classes of Preferred Stock; (b) setting by the Board of Directors of
the number of shares of Preferred Stock to be included in each such class; (c)
establishment by the Board of Directors of the preferences, conversion and other
rights, voting powers, restrictions, limitations as to dividends, qualifications
and terms and conditions of redemption of each such class of Preferred Stock;
(d) filing by the Company with the 
<PAGE>
 
BALLARD SPAHR ANDREWS & INGERSOLL
 
Kilroy Realty Corporation
February 11, 1998
Page 4


Department of Articles Supplementary setting forth a description of each such
class of Preferred Stock, including the preferences, conversion and other
rights, voting powers, restrictions, limitations as to dividends, qualifications
and terms and conditions of redemption as set by the Board of Directors and a
statement that the Preferred Stock has been classified by the Board of Directors
under the authority contained in the Charter, and the acceptance for record by
the Department of such Articles Supplementary; and (e) due authorization by the
Board of Directors of a designated number of shares of Preferred Stock for
issuance at a minimum price or value of consideration to be set by the Board of
Directors, all necessary corporate action on the part of the Company will have
been taken to authorize the issuance and sale of such shares of Preferred Stock
and when such shares of Preferred Stock are issued and delivered against payment
of the consideration therefor as set by the Board of Directors, such shares of
Preferred Stock will be validly issued, fully paid and non-assessable.

     3.   Upon: (a) designation and titling by the Board of Directors of the
Warrants; (b) setting by the Board of Directors of the number of Warrants to be
issued; (c) establishment by the Board of Directors of the terms, conditions and
provisions of the Warrants; (d) due authorization by the Board of Directors of
the Warrants for issuance at a minimum price or value of consideration to be set
by the Board of Directors; and (e) reservation and due authorization by the
Board of Directors of the shares of Common Stock and the shares of Preferred
Stock of the Company issuable upon exercise of such Warrants in accordance with
the procedures set forth in paragraphs 1 and 2 above, at a minimum price or
value of consideration to be set by the Board of Directors, all necessary
corporate action on the part of the Company will have been taken to authorize
the issuance and sale of the Warrants, and when such Warrants are issued and
delivered against payment of the consideration therefor as set by the Board of
Directors, in accordance with the authorization by the Board of Directors and
the terms of any Warrants Agreement, and authenticated by the Warrant Agent,
such Warrants will constitute valid and binding obligations of the Company,
subject to bankruptcy, insolvency, reorganization and other laws affecting the
rights of creditors generally and the exercise of judicial discretion in
accordance with general principles of equity.

     We consent to the filing of this opinion as an exhibit to the Registration
Statement and further consent to the filing of this opinion as an exhibit to
applications to the securities 
<PAGE>
 
BALLARD SPAHR ANDREWS & INGERSOLL
 
Kilroy Realty Corporation
February 11, 1998
Page 5


commissioners of the various states of the United States for registration of the
Securities. We also consent to the identification of our firm as Maryland
counsel to the Company in the section of the Prospectus (which is a part of the
Registration Statement) entitled "Legal Matters."

     This opinion is limited to the present corporate laws of the State of
Maryland and we express no opinion with respect to the laws of any other
jurisdiction.  Furthermore, the opinions presented in this letter are limited to
the matters specifically set forth herein and no other opinion shall be inferred
beyond the matters expressly set forth herein.  Without limiting the generality
of the foregoing, we express no opinion with respect to any securities laws.

     The opinions set forth in this letter are rendered as of the date hereof
and are necessarily limited to laws now in effect and facts and circumstances
presently existing and brought to our attention.  We assume no obligation to
supplement this opinion if any applicable law is changed after the date hereof
or if we become aware of any facts or circumstances which now exist or which
occur or arise in the future and may change the opinions expressed herein after
the date hereof.

     The opinions expressed in this letter are for your use and the use of your
securities counsel, Latham & Watkins, in connection with the filing of the
Registration Statement and the rendering of opinions by Latham & Watkins in
connection therewith, and may not be relied upon by you or Latham & Watkins for
any other purpose, without our prior written consent.

                                  Very truly yours,
                                 
                                  /s/ Ballard Spahr Andrews & Ingersoll
