Years of high investment returns at Madoff Securities left bankers in the London office of JPMorgan Chase skeptical of the methods of company chief Bernard L. Madoff. While the bank reported its suspicions to British authorities in 2008, it never said a word to anyone in Washington, the Justice Department says.

On Tuesday, Madoff’s primary banker agreed to pay federal prosecutors and regulators more than $2 billion to resolve criminal charges that it failed to alert the government about Madoff’s Ponzi scheme.

Justice hit JPMorgan with a $1.7 billion penalty for violating the Bank Secrecy Act, a law that calls on financial firms to alert authorities to suspicious activity. The payout is the largest penalty for a violation of the law and will be distributed to Madoff’s victims.

“JPMorgan as an institution failed, and failed miserably,” Manhattan U.S. Attorney Preet Bharara, whose office led the government’s investigation, said during a news conference. “In part because of that failure, for decades Bernie Madoff was able to launder billions of dollars in Ponzi proceeds through a single set of accounts at JPMorgan.”

JPMorgan entered into a deferred-prosecution agreement that gives Justice the right to pursue criminal charges if the bank fails to live up to the terms of the settlement. As part of the deal, the bank must acknowledge the facts of the government’s case and overhaul its anti-money-laundering controls. None of its employees will face criminal charges.

In a separate deal, JPMorgan’s primary regulator, the Office of the Comptroller of the Currency, exacted a $350 million civil penalty for violations of federal banking law. Officials in the Treasury Department’s Financial Crimes Enforcement Network imposed a $461 million fine, which was satisfied by some of the money JPMorgan agreed to pay Justice.

The agreements were reached more than five years after Madoff was arrested for duping clients in a $50 billion Ponzi scheme. At the time of its collapse in December 2008, Madoff Securities held more than 4,000 client accounts, which purported to have a combined balance of about $65 billion. It turned out that the company had only $300 million in assets, according to a statement of facts included in the agreement.

Madoff, who is serving a 150-year prison sentence, banked with JPMorgan for two decades before authorities took him down. Prosecutors say that on two occasions, in 2007 and 2008, JPMorgan’s internal systems raised alarms about Madoff’s investment activities.

In one instance in 2007, a Madoff account received $757.2 million in customer wires and transfers, 27 times the average daily value of such activity during the prior 90 days. Yet employees “closed the alerts with a notation that the transactions did not appear to be unusual,” according to the statement of facts.

JPMorgan has long maintained that it was not aware of Madoff’s scheme, much like the regulators and clients he deceived.

“We do not believe that any JPMorgan employee knowingly assisted Madoff’s Ponzi scheme,” company spokesman Brian Marchiony said in an e-mail. “We recognize we could have done a better job pulling together various pieces of information and concerns about Madoff from different parts of the bank over time.”

Marchiony said the firm is making “significant efforts” to strengthen its anti-money-laundering controls. JPMorgan chief executive Jamie Dimon told employees in a memo last year that the bank was spending about $1 billion to improve compliance operations.

Federal prosecutors’ investigation of JPMorgan is part of a broader effort to hold global banks accountable for ignoring the warning signs of fraud. The government took similar action against British banking giant HSBC, which agreed in 2012 to pay $1.9 billion for allowing Iran, Libya and Mexican drug cartels to move money through its branches.

As in the JPMorgan case, federal prosecutors imposed a deferred-prosecution agreement on HSBC, a move that was widely criticized as being tantamount to a slap on the wrist, as no executives faced criminal charges.

Tuesday’s settlements will bring JPMorgan closer to putting to rest its mountain of legal woes. In November, the bank earned the dubious distinction of paying the largest penalty dealt to a single company with its $13 billion settlement to resolve allegations that it sold faulty mortgage securities.

The financial goliath is still embroiled in federal investigations into tactics used to collect credit card debts, among other matters. There are dozens of private lawsuits against JPMorgan, including a few from Madoff investors that claim the bank aided and abetted his fraud.

On Tuesday, the bank reached a $543 million agreement with Irving Picard, the trustee liquidating Madoff’s firm, to resolve one of those cases.

Picard’s lawsuit revealed what it called internal communications suggesting that bank executives were aware of Madoff’s schemes as far back as 1997. At the time, according to the complaint, another financial institution raised concerns about his transactions. According to the lawsuit, a Madoff employee would deposit a check for between $1 million and $10 million into his account at JPMorgan almost every day, after drawing down the same amount at the other institution. The next day, the same amount would be wired back from Madoff’s JPMorgan account to the other institution to make it appear he had twice as much money during that period. The lawsuit cited a 2007 e-mail from John Hogan, then a senior risk officer at JPMorgan, discussing the suspicions of another bank executive.

“For whatever it’s worth, I am sitting at lunch with Matt Zames who just told me that there is a well-known cloud over the head of Madoff and that his returns are speculated to be part of a Ponzi scheme,” Hogan wrote, according to the lawsuit.

Despite nagging questions about Madoff’s operations, JPMorgan did not alert regulators and continued to handle billions of dollars for his brokerage firm, according to the complaint. Picard claims that JPMorgan earned an estimated $500 million in fees, interest payments and revenue from the firm.