A New York federal judge on Friday dismissed a long-running legal malpractice suit brought by Carl Icahn-controlled CVR Energy against Wachtell, Lipton, Rosen & Katz.

“We will definitely appeal the court's ruling,” said CVR's attorney, Herbert Beigel. “We're going to do everything we can to preserve our claims because we disagree with the court's decision.”

Wachtell has been battling CVR Energy's legal malpractice lawsuit for about five years. The refining and fertilizer company alleged Wachtell failed to advise that CVR would face claims by Deutsche Bank AG and The Goldman Sachs Group Inc. for $36 million under the terms of engagement letters with the banks.

But in a decision Friday, U.S. District Judge Richard Sullivan of the Southern District of New York said an attorney “cannot be liable for malpractice where the client 'negotiated and controlled the terms' of an agreement 'it now finds unfavorable.'” The judge noted that Frank Pici, CVR's CFO, “negotiated the business terms of the banks' fees.”

Significantly, the judge said, CVR's complaint does not assert that Wachtell had the authority to modify the fee terms in the engagement letters or that it was asked to do so. CVR, Sullivan said, failed to properly allege that Wachtell committed malpractice by failing to negotiate fair and appropriate fees with Goldman and Deutsche Bank.

CVR also claimed Wachtell inaccurately explained the fee terms during a February 2012 board meeting. But Sullivan, ruling on Wachtell's motion for a judgment on the pleadings, said this argument couldn't stand.

Although an attorney's “incorrect explanation of the contents of legal documents” may provide a sufficient basis for a legal malpractice claim, Sullivan said, New York law is clear that there can be “no malpractice liability” for failure to advise a client of the consequences of a contractual provision where “the agreement reveals on its face what the client claims he was not told.”

If a risk is “plainly stated,” an attorney cannot be liable for failing to explain it, Sullivan said, adding the engagement letters here were disclosed to CVR's general counsel and the terms of the engagement letters are “plain on their face.”

CVR recently sought to amend the lawsuit, alleging it had recently learned that Wachtell based its $6 million legal fee to CVR on the amount charged by the investment banks, which, the company claimed, was not consistent with the terms of the law firm's engagement letter with CVR.

CVR sought permission to add new claims for breach of contract and breach of the covenant of good faith and fair dealing.

The judge, noting fact discovery in the case closed in July, said CVR's proposed “belated addition” of these claims “smacks of bad faith and undue delay.”

Sullivan ruled that the additions CVR proposed “do almost nothing to address the fatal deficiencies.” However, the judge allowed CVR to recast one of its theories of malpractice against the law firm.

CVR claimed that Wachtell's “negligent preparation” of certain SEC forms was reckless and grossly negligent, resulting in an investigation that cost over $1.5 million in legal fees and an order finding CVR in violation of SEC regulations.

Sullivan, noting that the order was issued after CVR filed its complaint, said he would allow CVR to amend its pleading only as to its SEC disclosure theory.

Wachtell, represented by Michael Shuster of Holwell Shuster & Goldberg, declined to comment.

READ MORE: