Credit Suisse has agreed to pay $495 million as part of a settlement with the U.S. over a yearslong dispute tied to mortgage-backed securities, an investment vehicle that played a central role in the 2008 financial crisis.

The Swiss bank said that some of the transactions were prior to 2008.

The New Jersey Attorney General, which announced the settlement Monday, filed a lawsuit in 2013 alleging more than $3 billion in damages citing the involvement of Credit Suisse.

“This agreement in principle holds Credit Suisse accountable for the loss of billions of dollars that helped put the nation in financial crisis,” said First Assistant Attorney General Lyndsay Ruotolo. “It has taken more than a decade of investigation and litigation to reach this historic result, but we never wavered in our resolve to get here. The recovery Credit Suisse has agreed to pay reflects the magnitude of harm it inflicted on the public and underscores New Jersey’s commitment to vigorously pursue cases, no matter the challenges, to protect the financial interests of the investing public.”

Credit Suisse said Monday that the settlement allows the bank to resolve its only remaining mortgage-backed securities matter involving claims by a regulator, the largest it faced.

Credit Suisse has run into a series of troubles in recent years, including bad bets on hedge funds and a spying scandal involving UBS. Also, a Swiss court fined the bank more than $2 million in June for failing to prevent money laundering linked to a Bulgarian criminal gang more than 15 years ago.

In July Credit Suisse CEO Thomas Gottstein announced that he was resigning after 2-1/2 years in the job.