<Page>


                                                                      EXHIBIT 5

                                January 31, 2003


International Business Machines Corporation
New Orchard Road
Armonk, NY 10504

Ladies and Gentlemen:

I am Assistant Secretary and Associate General Counsel of International Business
Machines Corporation (herein called the "Corporation") and an attorney duly
admitted to practice in the State of New York. I am familiar with the
Registration Statement on Form S-8 (the "Registration Statement") under the
Securities Act of 1933 (the "Securities Act") regarding the shares of common
stock, par value $.20 per share, of the Corporation (the "Shares") to be issued
pursuant to the IBM PWCC Acquisition Long-Term Performance Plan (the "Plan").

I have reviewed such documents and records as I have deemed necessary or
appropriate to enable me to express an informed opinion with respect to the
matters covered hereby.

Based upon the foregoing, I am of the opinion that, when issued or sold in
accordance with the terms of the Plan, the Shares will be duly authorized,
validly issued, fully paid and nonassessable. The Plan does not require
shareholder approval because directors and officers (as defined in Section 16 of
the Securities Exchange Act of 1934, as amended) will not be receiving awards
under the Plan.

I hereby consent to the use of my name in the Registration Statement as the
legal counsel who has passed upon the legality of the Shares, as well as to the
use of this legal opinion as part of the Registration Statement, as an Exhibit
to the Registration Statement.

                                   Very truly yours,





                                   /S/ ANDREW BONZANI
                                   --------------------------------
                                   ANDREW BONZANI, ESQ.
                                   ASSISTANT SECRETARY AND ASSOCIATE
                                   GENERAL COUNSEL