<DOCUMENT>
<TYPE>EX-5.1
<SEQUENCE>3
<FILENAME>a2077063zex-5_1.txt
<DESCRIPTION>OPINION OF WSGR
<TEXT>
<Page>

                                                                     Exhibit 5.1

                                 April 16, 2002

Hewlett-Packard Company
3000 Hanover Street
Palo Alto, California 94304

     RE:  REGISTRATION STATEMENT ON FORM S-3

Ladies and Gentlemen:

     We have examined the Registration Statement on Form S-3 to be filed by you
with the Securities and Exchange Commission on or about the date hereof (the
"Registration Statement") in connection with the registration under the
Securities Act of 1933, as amended, of an aggregate of up to 21,126,566 shares
(the "Shares") of your common stock for issuance under Compaq Computer
Corporation's 2001 Stock Option Plan, 1998 Stock Option Plan, 1995 Equity
Incentive Plan, 1989 Equity Incentive Plan, 1985 Stock Option Plan, 1985
Executive and Key Employee Stock Option Plan, 1985 Nonqualified Stock Option
Plan, 1998 Former Non-employee Replacement Option Plan, and Nonqualified Stock
Option Plan for Non-Employee Directors (collectively, the "Plans").

     As your legal counsel, we have examined the proceedings taken and are
familiar with the proceedings proposed to be taken by you in connection with the
sale and issuance of the Shares under the Plans. In addition, for purposes of
this opinion we have assumed that the consideration received by the Company in
connection with each issuance of the Shares will include an amount in the form
of cash, services rendered or property that exceeds the greater of (i) the
aggregate par value of such Shares or (ii) the portion of such consideration
determined by the Company's Board of Directors to be "capital" for purposes of
the Delaware General Corporation Law.

     Based upon the foregoing, it is our opinion that, when issued and sold in
the manner referred to in the respective Plan and pursuant to the agreements
which accompany the respective Plan, the Shares issued and sold thereby will be
legally and validly issued, fully paid and non-assessable.

     We consent to the use of this opinion as an exhibit to the Registration
Statement and further consent to the use of our name wherever appearing in the
Registration Statement, including any prospectus constituting a party thereof
and any amendments thereto.

                                        Very truly yours,

                                        WILSON SONSINI GOODRICH & ROSATI
                                        Professional Corporation

                                        /s/ Wilson Sonsini Goodrich & Rosati

</TEXT>
</DOCUMENT>
