The lawsuit filed in February alleged that Chief Executive Jamie Dimon and 12 other current and former executives and directors turned "a blind eye to Madoff's thievery."

The claims were based partly on statements Madoff gave in a series of interviews - including conversations with plaintiffs lawyers while in federal prison in North Carolina - about his interactions with the bank. Madoff was an important client of the bank for two decades.

Judge Paul Crotty ruled there were not enough specific facts to prove the board breached their duties to shareholders.

"Any alleged red flags are insufficient to demonstrate bad faith on the part of the outside directors," Crotty wrote in his opinion.

JP Morgan spokeswoman Kristen Chambers said the bank declined to comment. An attorney for the plaintiffs did not immediately respond to a request for comment.

The lawsuit, filed in New York federal court, was brought by the Steamfitters Local 449 Pension Fund in Pittsburgh and Central Laborers' Pension Fund in Jacksonville, Illinois, both shareholders of JPMorgan.

The action came after JPMorgan agreed to pay $2.6 billion to settle other lawsuits over its Madoff dealings.

In those accords JPMorgan entered a "deferred prosecution agreement," or DPA, to resolve criminal charges, under which the bank acknowledged its responsibility for failing to stop Madoff before his scheme surfaced publicly in December 2008.

Madoff, 76, is serving a 150-year prison term after pleading guilty to fraud in March 2009.

The case is Central Laborers' Pension Fund et al v. Dimon et al, U.S. District Court, Southern District of New York, No 14-01041.

(Reporting by Mica Rosenberg and Jonathan Stempel; Editing by Eric Walsh)