EXHIBIT 5.1

OPINION OF COUNSEL

[Davis Polk & Wardwell letterhead]

June 22, 2007

KLA-Tencor Corporation

160 Rio Robles

San Jose, California 95134-1809

Re: Registration Statement on Form S-8

Ladies and Gentlemen:

KLA-Tencor Corporation, a Delaware corporation (the “Company”), is filing with the Securities and Exchange Commission a Registration Statement on Form S-8 (the “Registration Statement”) for the purpose of registering under the Securities Act of 1933, as amended (the “Securities Act”), an aggregate of 30,000 shares of its common stock, par value $0.001 per share (the “Common Stock”), issuable pursuant to the Therma-Wave, Inc. 2000 Equity Incentive Plan (as amended to the date hereof, the “Plan”), as described in the Registration Statement.

We, as your counsel, have examined such documents and such matters of fact and law that we have deemed necessary for the purpose of rendering the opinion expressed herein. Based on the foregoing, we advise you that, in our opinion, when the Common Stock has been duly issued and delivered in accordance with the terms and conditions of the Plan, the Common Stock will be validly issued, fully paid and non-assessable.

We are members of the Bars of the States of New York and California and the foregoing opinion is limited to the federal laws of the United States and the General Corporation Law of the State of Delaware.

We hereby consent to the filing of this opinion as an Exhibit to the Registration Statement. In giving this consent, we do not admit that we are in the category of persons whose consent is required under Section 7 of the Securities Act.

Sincerely,

/S/    DAVIS POLK & WARDWELL