Exhibit 5.1

August 5, 2025
BancFirst Corporation
100 North Broadway
Oklahoma City, Oklahoma 73102
Re: Registration Statement on Form S-8
Ladies and Gentlemen:
We have acted as counsel to BancFirst Corporation, an Oklahoma corporation (“Company”), in connection with the proposed registration by the Company of an aggregate of 25,901 shares (“Shares”) of Common Stock, par value $1.00 per share, of the Company issuable to non-employee directors under the Amended and Restated BancFirst Corporation Directors’ Deferred Stock Compensation Plan, as amended (“Plan”). The Shares are being registered with the Securities and Exchange Commission (“Commission”) pursuant to a registration statement on Form S-8 (as amended or supplemented, “Registration Statement”), to be filed with the Securities and Exchange Commission under the Securities Act of 1933, as amended (“Securities Act”).
We have examined originals or copies, certified or otherwise identified to our satisfaction, of (a) the Registration Statement, (b) the certificate of incorporation of the Company, as amended, (c) the bylaws of the Company, as amended, (d) the Plan and (e) such other documents as we deemed necessary for the expression of the opinions rendered herein.
For purposes hereof, we have relied, without investigation, upon the accuracy and the completeness of each document submitted to us for review, the authenticity of each document submitted to us as an original and the conformity to the original document of each such document that is submitted to us as a copy. As to any opinions material to the opinions expressed herein that we have not independently established or verified, we have relied upon statements of the officers of the Company without independent review.
Based on the foregoing, we are of the opinion that the Shares issuable upon exercise according to the terms of the Plan are validly authorized and, when issued in accordance with the terms of the Plan, and assuming no change in the law or facts as exist as of the date hereof, will be validly issued, fully paid and non-assessable.