NEW YORK (AP) — The Federal Reserve Bank of New York sold the remainder of the securities that it had bought as part of the rescue of beleaguered insurance giant American International Group during the financial crisis.

On Thursday, the New York Fed said the sale of the securities will result in a net gain to the American taxpayers of $6.6 billion. During the financial crisis, AIG was brought to its knees when it couldn't meet obligations tied to securities that had plummeted in value. The Fed and the U.S. Treasury stepped in with a package of loans and guarantees totaling $182.5 billion to rescue the New York-based insurance giant from collapse in 2008 and 2009.

As part of the package, the Fed gave out loans and also bought some of the most toxic securities from AIG and its counterparties, which included some of the largest financial firms in the country.

New York Fed President William Dudley said the sale of the securities "marks the end of an important chapter — our assistance to AIG — that was undertaken to stabilize the financial system in the midst of the financial crisis."

AIG has earlier repaid the loans it had taken from the Fed with interest. According to the Fed, taxpayers have made a total profit of $17.7 billion from its assistance to AIG.

Though the Fed has managed to make a profit from the help it extended AIG, the U.S. taxpayer hasn't yet been made whole on its entire investment in AIG. That's because the government is still AIG's largest shareholder.

The Treasury Department owns about 53 percent of AIG stock. It has brought down its stake from 92 percent after selling shares four times in the last couple of years for a total of $23.3 billion.