GENEVA—The U.S. government has reached "an agreement in principle" to settle its lawsuit against Swiss banking giant UBS AG that seeks to recoup more than $900 million in losses from mortgage-backed securities, the bank announced Monday.

In 2011, the U.S. government sued UBS and 17 other financial firms for selling some $196 billion worth of mortgage-backed securities to housing financing agencies Fannie Mae and Freddie Mac. However the securities turned toxic when the housing market collapsed.

Among the major U.S. banks targeted by the lawsuits were Bank of America Corp., Citigroup Inc., JPMorgan Chase & Co., and Goldman Sachs Group Inc., but the action extended to other large European banks including The Royal Bank of Scotland, Barclays Bank and Credit Suisse.

Fannie and Freddie, which are overseen by the U.S. Federal Housing Finance Agency, buy mortgage loans and securities issued by banks so that the lenders use the money to reinvest in the property market. The two agencies invested heavily in residential mortgage-backed securities, which bundled pools of mortgages into complex investments that collapsed after the real-estate bust and helped fuel the financial crisis in late 2008.

UBS released no more details or costs of the settlement, which it said still required "final approvals by the parties."

The Swiss banking giant also announced Monday that its net profit jumped 62 percent in the second quarter of the year to 690 million francs ($734 million), up from 425 million francs in the same period a year earlier. UBS said it was making progress with its strategic overhaul.

But the second-quarter improvement is still way down the 1.02 billion Swiss francs that the Zurich-based bank reported in the comparable period in 2011. The basic results were released unexpectedly, a week ahead of a planned second-quarter report.