
<PAGE>
                                                                       EXHIBIT 5
 
                                  February 9, 1998
 
Board of Directors
First Empire State Corporation
One M&T Plaza
Buffalo, NY 14240
 
Ladies and Gentlemen:
 
    This opinion is rendered in connection with the Registration Statement on
Form S-4 (the "Registration Statement") of First Empire State Corporation, a New
York corporation ("FESC"), to be filed with the Securities and Exchange
Commission under the Securities Act of 1933, as amended (the "Securities Act"),
relating to the registration of 1,510,000 shares of FESC's common stock, par
value $5.00 ("FESC Common Stock"), in connection with that certain Agreement and
Plan of Reorganization dated as of October 28, 1997 (the "Reorganization
Agreement"), by and among FESC, ONBANCorp, Inc. ("OBC"), a Delaware corporation,
and Olympia Financial Corp. ("Olympia"), a Delaware corporation and wholly owned
subsidiary of FESC, and that certain related Agreement and Plan of Merger dated
as of October 28, 1997 (the "Merger Agreement" and together with the
Reorganization Agreement, the "Agreements"), by and among FESC, OBC and Olympia.
Subject to certain conditions, the Agreements provide for the merger (the
"Merger") of OBC with and into Olympia.
 
    As Senior Vice President and General Counsel of FESC, I have participated in
the preparation of the Registration Statement, including the prospectus included
therein. I have acted as counsel to FESC with respect to the authorization and
issuance of the FESC Common Stock covered by the Registration Statement. I have
reviewed FESC's Certificate of Incorporation and By-laws, each as amended to
date, the Registration Statement, the Agreements and the proceedings taken by
FESC relating to the Agreements and the Registration Statement, including the
resolutions adopted by FESC's Board of Directors with respect thereto. I also
have examined such corporate records, certificates and other documents that I
have considered necessary or appropriate for the purposes of this opinion.
 
    In making such examination and rendering the opinions set forth below, I
have assumed: (i) the genuineness and authenticity of all signatures (other than
my own) on original documents; (ii) the authenticity of all documents submitted
to me as originals; and (iii) the conformity of originals of all documents
submitted to me as certified, telecopied, photostatic or reproduced copies and
the authenticity of all originals of such documents.
 
    In addition, I have assumed: (a) the due authorization and issuance of the
outstanding shares of common stock of OBC, and (b) that the Option Plans (as
defined below) and any stock options issued thereunder have been duly authorized
on OBC's part in accordance with applicable law. I am admitted to practice law
in the State of New York and do not purport to be an expert on or to express any
opinion on any laws other than the laws of the State of New York and the federal
laws of the United States of America. This opinion speaks as of today's date and
is limited to present statutes, regulations and judicial interpretations. In
rendering this opinion, I assume no obligation to revise or supplement this
opinion should the present laws be changed by legislative or regulatory action,
judicial decision or otherwise.
<PAGE>
Board of Directors
First Empire State Corporation
February 9, 1998
Page 2
 
    Based upon the foregoing, I am of the opinion that:
 
        (1) The shares of FESC Common Stock have been duly authorized and, when
    issued to the stockholders of OBC pursuant to, and in accordance with, the
    terms of the Agreements, will be validly issued, fully paid and
    nonassessable.
 
        (2) Upon the effectiveness of the Merger, the shares of FESC Common
    Stock included in the Registration Statement that may be issued to holders
    of stock options granted by OBC under the 1992 OBC Directors' Stock Option
    Plan, the OBC 1987 Stock Option and Appreciation Rights Plan or the Franklin
    First Savings Bank Incentive Plan (collectively, the "Option Plans") and to
    be assumed by FESC pursuant to Paragraph 6 of Article V of the Merger
    Agreement, upon issuance in accordance with the terms of the Option Plans
    for lawful consideration, will be validly issued, fully paid and
    nonassessable.
 
    This letter does not address any matters other than those expressly
addressed herein.
 
    I hereby consent in the filing of this opinion as an exhibit to the
Registration Statement and to the reference to me under the caption "Legal
Opinion" in the prospectus, which is part of the Registration Statement. In
giving such consent, I do not thereby admit that I am in the category of persons
whose consent is required under Section 7 of the Securities Act.
 
<TABLE>
<S>                             <C>  <C>
                                Very truly yours,
 
                                            /s/ RICHARD A. LAMMERT
                                 ---------------------------------------------
                                              Richard A. Lammert
                                           SENIOR VICE PRESIDENT AND
                                                GENERAL COUNSEL
</TABLE>
