A U.S. judge on Friday dismissed five out of nine claims against Bank of New York Mellon over its foreign exchange pricing practices, and shipped off four remaining claims to be tried in different state courts, according to a ruling.

U.S. District Judge William Alsup in San Francisco gave the plaintiffs 21 days to file an amended lawsuit that attempts to address the deficiencies he found in their complaint.

Legal battles have raged for several years over claims that custodial banks, mainly BNY Mellon and State Street , routinely overcharged pension funds and other institutional clients on currency transactions.

State Street was sued in October 2009 by the California attorney general over its foreign-exchange practices. Last August, state officials in Florida and Virginia sued BNY Mellon, joining whistleblower lawsuits originally filed by the group FX Analytics.

Along with several pension funds, FX Analytics is also a plaintiff in the lawsuit before Alsup. The judge dismissed allegations that BNY Mellon violated California's False Claims Act, and he transferred additional allegations brought by the funds to state court.

Attorneys for both sets of plaintiffs could not immediately be reached on Friday.

BNY Mellon spokesman Kevin Heine on Friday said the ruling has essentially reduced the lawsuit to a basic breach of contract case. The bank will vigorously defend the remaining claims, he said.

We are pleased that this respected federal court has vindicated our position and dismissed the most serious claims against us, Heine said.

BNY Mellon reached a partial settlement with U.S. prosecutors in January over civil fraud charges brought by the government.

Under the settlement, the two sides said, the bank would disclose how it determines prices for certain transactions. There was no mention of a monetary settlement, but the court documents said the parties were continuing discussions.

The government sought hundreds of millions of dollars in civil penalties.

In his ruling on Friday, Alsup ruled that monthly reports reflecting fictitious trades for FX rates were not the same as false claims for payment. Thus the plaintiffs could not allege False Claims Act violations based on those reports, he ruled.

The case in U.S. District Court, Northern District of California is In re Bank of New York Mellon Corporation False Claims Act Foreign Exchange Litigation, 11-5683.

(Reporting By Dan Levine; Editing by Bob Burgdorfer, Gary Hill)