The bank will pay $1.7 billion to settle criminal charges and a $350 million civil penalty for what the Treasury Department called "critical and widespread deficiencies" in its programs to prevent money laundering and other suspicious activity.
It also will pay $543 million to settle other victim claims, according to settlements announced by Irving H. Picard, the trustee recovering money for thousands of Madoff's victims.
George Venizelos, head of the FBI's New York office, said the company failed to carry out its legal obligations while Madoff "built his massive house of cards."
"It took until after the arrest of Madoff, one of the worst crooks this office has ever seen, for JPMorgan to alert authorities to what the world already knew," he said.
JPMorgan, the primary bank through which Madoff operated since 1986, withdrew about $300 million of its own money from Madoff feeder funds in 2008, soon after the bank's London desk circulated a memo describing JPMorgan's inability to validate Madoff's trading activity or custody of assets and his "odd choice" of a one-man accounting firm, the government said.
U.S. Attorney Preet Bharara said in a release that "JPMorgan connected the dots when it mattered to its own profit, but was not so diligent otherwise."
He added that financial institutions "must exercise due care not only with their own money but with other people's money also."
The $1.7 billion represents the largest forfeiture by a U.S. bank and the largest Department of Justice penalty for a Bank Secrecy Act violation, the government said.
The settlement includes a so-called deferred prosecution agreement that requires the bank to acknowledge failures in its protections against money laundering but also allows it to avoid criminal charges. No individual executives were accused of wrongdoing.
The agreement resolves two felony violations of the Bank Secrecy Act in connection with the bank's relationship with Bernard L. Madoff Investment Securities, the private investment arm of Madoff's former business.
The civil penalty was imposed by the Treasury Department's Office of the Comptroller of the Currency.
The government said the penalty was assessed because the bank failed to pass along to U.S. authorities suspicions about Madoff it had reported to Britain's Serious Organised Crime Agency, and because the bank failed to detect and report other cases of suspicious activity, including more than $2 billion in transactions involving the Puerto Rican affiliate of an unidentified Venezuelan bank.
Under the agreement, criminal charges will be deferred for two years as JPMorgan admits to its conduct, pays the $1.7 billion to victims of Madoff's fraud and reforms its anti-money laundering policies, prosecutors said.
A statement of facts included in the agreement describes internal communications at JPMorgan expressing concerns about how Madoff was generating his purported returns. It says executives were disturbed by the fact that Madoff wouldn't let the bank examine his books.
"How much do we have in Madoff at the moment?" a bank analyst wrote in a 2008 email. "To be honest, the more I think about it, the more concerned I am."
In a statement, JPMorgan said it recognized it "could have done a better job pulling together various pieces of information and concerns about Madoff from different parts of the bank over time."
It noted that in late October 2008 it filed the U.K. suspicious activity report but didn't file one in the United States. The fraud was revealed with Madoff's arrest in December 2008.
"We do not believe that any JPMorgan Chase employee knowingly assisted Madoff's Ponzi scheme," the bank said. "Madoff's scheme was an unprecedented and widespread fraud that deceived thousands, including us, and caused many people to suffer substantial losses."
It said it was making "significant efforts" to strengthen its anti-money-laundering practices and believed "the lessons we have learned will make us a stronger company."
Its shares fell 65 cents to $58.35 in late afternoon trading Tuesday.
The deal was similar to one reached in late 2012 with the British bank HSBC, which agreed to pay $1.9 billion to settle claims it laundered money for Iran, Libya and Mexico's murderous drug cartels.
JPMorgan was Madoff's primary bank in the later years of a multi-decade fraud that ended in 2008 when he revealed to the FBI that his investment advisory business was a Ponzi scheme.
Account statements for thousands of clients showing $60 billion in assets were fiction. Of the roughly $17.5 billion in principal that was real, most of it was gone.
Since then, Picard has recovered more than $9.5 billion to redistribute to burned clients.
The trustee sued JPMorgan for $6.4 billion in 2010, accusing the bank of being "wilfully blind" and "thoroughly complicit" in the fraud, but an appeals court found in 2012 that he had no legal standing to make the claim.
The JPMorgan settlement is the latest in a series of major deals it has made to resolve its legal troubles. In November, the bank agreed to pay $13 billion over risky mortgage securities it sold before the financial crisis - the largest settlement to date between the Justice Department and a corporation.
JPMorgan still has several lawsuits pending against it related to the high-risk mortgage bonds that soured after the housing market collapsed in 2007. There's also an ongoing criminal investigation led by the office of U.S. Attorney Benjamin Wagner in Sacramento, Calif.
The bank may be negotiating or litigating over the issue for years and has set aside $23 billion to cover those costs. JPMorgan told regulators in a filing in October that it may need as much as $5.7 billion more.
Madoff, 75, pleaded guilty and is serving a 150-year prison term.
AP Business Writer Marcy Gordon in Washington contributed to this report.