
<PAGE>
 
                                                                      EXHIBIT 5
 
 
                               February   , 1998
 
 
(415) 393-8200                                                    C 38126-00343
 
Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304
 
  Re: $2,000,000,000 Aggregate Principal Amount at Maturity of Liquid Yield
      Option(TM) Notes Due 2017 (Zero Coupon-Subordinated)
 
Ladies and Gentlemen:
 
  We have acted as special counsel to Hewlett-Packard Company, a California
corporation (the "Company"), in connection with (i) the issuance and sale by
the Company of $2,000,000,000 aggregate principal amount at maturity of Liquid
Yield Option(TM) Notes due 2017 (the "LYONs(TM)" ) on October 14, 1997 in
transactions exempt from the registration requirements of the Securities Act
of 1933, as amended (the "Act"), and (ii) the filing of the Company's
Registration Statement on Form S-3 to which this opinion is an Exhibit (the
"Registration Statement") with respect to the offer and sale of the LYONs by
the several holders of the LYONs (the "Selling Holders").
 
  We are familiar with the corporate action taken by the Company in connection
with the authorization, issuance and sale of the LYONs and have made such
other legal or factual inquiries as we deemed necessary or appropriate for
purposes of rendering this opinion.
 
  We have assumed the genuineness of all signatures, the legal capacity of
natural persons, the authenticity of all documents submitted to us as
originals, and the conformity to original documents of all documents submitted
to us as copies and the authenticity of the originals of such copied
documents.
 
  On the basis of and in reliance upon the foregoing, and subject to the
assumptions, qualifications, limitations and exceptions contained herein, we
are of the opinion that:
 
  1. The LYONs are validly issued, fully paid and non-assessable and are valid
and binding obligations of the Company entitled to the benefits of the
Indenture, dated as of October 14, 1997, by and between the Company and Chase
Manhattan Bank and Trust Company, National Association, as trustee, as now or
hereafter supplemented, under which the LYONs were issued (the "Indenture");
and
 
  2. The shares of Common Stock, par value $1.00 per share, of the Company
issuable upon conversion of the LYONs (the "Shares"), when issued in
accordance with the terms of the Indenture, will be validly issued, fully paid
and non-assessable.
 
  The opinions set forth above are subject to the following assumptions,
qualifications, limitations and exceptions being true and correct at or prior
to the time of the delivery of any of the Shares:
 
    (a) at the time any of the LYONs are offered or sold, (i) the Registration
Statement will be effective or such LYONs will be sold in a transaction exempt
from the requirements of the Act and (ii) all applicable "Blue Sky" and state
securities laws will have been complied with; and
 
    (b) the Indenture has been qualified under the Trust Indenture Act of
1939, as amended.
--------
(TM) Trademark of Merrill Lynch & Co., Inc.
<PAGE>
 
  Our opinion set forth in numbered paragraph 1 above is subject to the effect
of (i) applicable bankruptcy, reorganization, insolvency, moratorium and other
similar laws and court decisions of general application (including, without
limitation, statutory or other laws regarding fraudulent or preferential
transfers) relating to, limiting or affecting the enforcement of creditors'
rights generally, (ii) general principles of equity that may limit the
enforceability of any of the remedies, covenants or other provisions of the
LYONs and the Indenture, and (iii) the application of principles of equity
(regardless of whether enforcement is considered in proceedings at law or in
equity) as such principles relate to, limit or effect the enforcement of
creditors' rights generally.
 
  We express no opinion as to (i) any provision of the LYONs or the Indenture
regarding the remedies available to any person (A) to take action that is
arbitrary, unreasonable or capricious or is not taken in good faith or in a
commercially reasonable manner, whether or not such action is permitted under
the LYONs or the Indenture, or (B) for violations or breaches that are
determined by a court to be non-material or without substantially adverse
effect upon the ability of the Company to perform its material obligations
under the LYONs or the Indenture; or (ii) any provision of the LYONs or the
Indenture that may provide for interest on interest or penalty interest.
 
  This opinion is limited to California, New York and federal law.
 
  You have informed us that the Selling Holders may sell the LYONs or the
Shares from time to time after the date of the Registration Statement, and
this opinion is limited to the laws referred to above as in effect on the date
hereof.
 
  This opinion may not be quoted in whole or in part without our prior written
consent.
 
  We hereby consent to the use of our name under the caption "Legal Matters"
in the Prospectus forming a part of the Registration Statement and to the
filing of this opinion as an Exhibit to the Registration Statement. In giving
this consent, we do not admit that we are within the category of persons whose
consent is required under Section 7 of the Act or the General Rules and
Regulations of the Securities and Exchange Commission.
 
                                          Very truly yours,
 
                                          GIBSON, DUNN & CRUTCHER LLP
 
                                       2
