Citigroup has agreed to pay $7 billion to the Justice Department to resolve investigations into its sales of troubled mortgage securities in the lead up to the financial crisis, ending months of contentious negotiations.

The probe centered on securities--pools of home loans that the nation's third largest bank issued, structured and underwrote between 2003 and 2008. Prosecutors uncovered evidence that Citigroup officials ignored warnings of the poor quality of the mortgages being bundled into bonds, even when more than 25 percent of loans under review were missing documents or included fishy stated income.

In an internal e-mail, a trader at Citigroup advised that colleagues "should start praying" because he "would not be surprised if half of these loans went down." He said he feared that there were "a lot of loans that have unreasonable incomes, value below the original appraisals," and found it "amazing that some of these loans were closed at all," according to the statement of facts in the settlement.

"Despite the fact that Citigroup learned of serious and widespread defects among the increasingly risky loans they were securitizing, the bank and its employees concealed these defects," Attorney General Eric H. Holder Jr. said at a news conference Monday. "They misrepresented the facts, including the level of risk. They sold defective loans to countless investors, including federally-insured financial institutions."

Justice said the settlement includes a $4 billion penalty, the largest of its kind. It also includes $500 million to state attorneys general and the Federal Deposit Insurance Corp. The remaining $2.5 billion will go towards various forms of consumer relief to be distributed by the end of 2018.

No bank executives were named in the civil agreement, though prosecutors said that does not preclude the department from taking civil or criminal action against individuals in the future. Holder declined to say whether the department is pursuing any individuals at this time.

Citigroup acknowledged the statement of facts laid out in the government's case, but did not admit wrongdoing.

"We believe that this settlement is in the best interests of our shareholders, and allows us to move forward and to focus on the future, not the past,” Michael Corbat, chief executive of Citigroup, said in a statement.

The bank said it will take a $3.8 billion pretax charge in the second quarter to cover the cost of the settlement. That expense helped sink profits 96 percent from the same period a year ago, with Citigroup on Monday reporting second quarter net income of $181 million.

Mortgage securities, once a brisk business for Wall Street, were at the heart of the crisis. Banks, after issuing loans, would pool the mortgages and market the bundles as investments. Prosecutors have accused Citigroup, Bank of America and JPMorgan Chase of packaging shoddy home loans into securities that they knew would go sour and selling them to unsuspecting investors around the world.

When the housing market crashed, the securities were worthless and left investors saddled with massive losses. Losses on mortgage investments nearly toppled the financial system. Lenders retreated from the market. Stock markets plummeted and home values took a nosedive.

Early on in its negotiations with Justice, Citigroup contended that its role in the securities business was minor compared to competitors. Citigroup packaged and sold $91 billion worth of the securities in question from 2004 to 2008, according to estimates from Sanford C. Bernstein analyst John McDonald. By comparison, Bank of America, including its Merrill Lynch unit, traded $965 billion, while JPMorgan Chase, including its Bear Sterns subsidiary, sold $450 billion.

Justice argued that Citigroup issued securities with a higher percentage of bad loans compared to its competitors and was well aware of the shoddy quality of loans it was pooling into bonds. In one instance, Citigroup purchased thousands of loans in 2007 from a mortgage originator, even though the seller labeled a substantial number of the loans as high risk.

"Citigroup employees often personally ordered the due diligence firms to change the loan grades from reject to accepted," Colorado U.S. Attorney John Walsh said during the press conference. "Often Citi employees ordered a particular loan to be accepted, without explaining the reason."

Monday's settlement concludes a two- year investigation that included nearly 50 subpoenas to Citigroup, trustees, servicers, due diligence providers and their employees, according to Justice. Prosecutors collected nearly 25 million documents relating to securities issued or underwritten by Citigroup in 2006 and 2007.

The deal is the handiwork of the Obama administration’s residential mortgage-backed securities group — a team of federal and state attorneys assembled in 2012 to go after crimes related to the financial crisis. The team was behind the landmark $13 billion settlement with JPMorgan over its role in selling faulty mortgage securities to investors.

Associate Attorney General Tony West, the lead negotiator on the Citgroup and JPMorgan deals, said the group is investigating "several" other banks for their role in misleading investors about the quality of the mortgage bonds they sold. He declined to name names, but said the group was close to wrapping up many of those probes.

Justice has been in talks with Bank of America over its role in selling faulty mortgage securities, but talks reached an impasse last month as the two sides could not agree on the terms of the deal.

Bank of America offered to pay more than $12 billion to end several ongoing investigations, a figure that rivals the $13 billion JPMorgan deal, according to people familiar with the talks. But the bank could not come to an agreement on how much money it would set aside to help struggling homeowners.