
<PAGE>   1


                                                                     EXHIBIT 5.1


                        [LETTERHEAD OF GABLE & GOTWALS]


                                 March 10, 2000


ONEOK, Inc.
PO Box 871
Tulsa, OK 74102-0871

         Re: Registration Statement on Form S-4

Ladies & Gentlemen:

     We have acted as counsel to ONEOK, Inc., an Oklahoma corporation (the
"Company"), in connection with the preparation of a Registration Statement on
Form S-4 (the "Registration Statement") filed by the Company with the Securities
and Exchange Commission with respect to up to $350 million aggregate principal
amount of the Company's 7.75% Notes Due 2005, Series B (the "Exchange Notes"),
which will be offered in exchange for the Company's issued and outstanding 7.75%
Notes Due 2005 (the "Old Notes"), as described in the Registration Statement.

     The Exchange Notes are to be issued in exchange for the Old Notes pursuant
to the Indenture dated as of September 24, 1998 (the "Indenture") between the
Company and Chase Bank of Texas, National Association, as Trustee (the
"Trustee"), as amended by a Sixth Supplemental Indenture dated as of March 1,
2000, between the Company and the Trustee (the "Sixth Supplemental Indenture"),
and pursuant to the Registration Rights Agreement dated as of March 1, 2000,
among the Company, Banc of America Securities L.L.C., Bank One Capital Markets,
Inc., First Union Securities, Inc., J.P. Morgan Securities Inc., PaineWebber
Incorporated and Salomon Smith Barney Inc. (the "Registration Rights
Agreement").

     In so acting, we have examined and have relied upon such records, documents
and other instruments as in our judgment are necessary or appropriate in order
to express the opinion hereinafter set forth and have assumed the genuineness of
all signatures, the authenticity of all documents submitted to us as originals
and the conformity to original documents of all documents submitted to us as
certified or photostatic copies.

     Based upon and subject to the foregoing, we are of the opinion that the
Exchange Notes, when duly executed and authenticated in accordance with the
terms of the Indenture, as amended


<PAGE>   2


ONEOK, Inc.
March 10, 2000
Page 2


by the Sixth Supplemental Indenture, and delivered in exchange for the Old Notes
in accordance with the terms of the Indenture, as amended by the Sixth
Supplemental Indenture, will have been validly issued and will be legally
binding obligations of the Company, subject to the following exceptions,
limitations and qualifications: (a) the effect of bankruptcy, insolvency,
reorganization, arrangement, moratorium, fraudulent conveyance, fraudulent
transfer and other similar laws relating to or affecting the rights and remedies
of creditors generally and (b) general principles of equity (including, without
limitation, concepts of materiality, reasonableness, good faith and fair dealing
and the possible unavailability of specific performance, injunctive relief or
other equitable remedies), regardless of whether considered in a proceeding at
law or in equity, and the discretion of the court before which any proceeding
therefor may be brought.

     We express no opinion herein other than as to the laws of the State of
Oklahoma and the federal laws of the United States.

     We hereby consent to the reference to our law firm in the Registration
Statement under the caption "Legal Matters" and to the use of this opinion as an
exhibit to the Registration Statement.

                                             Very truly yours,


                                             /s/ JOHN R. BARKER


                                             John R. Barker
                                             For the Firm

JRB:jh
