Citigroup Inc. and UBS AG on Thursday agreed to buy back a total of nearly $30 billion in risky auction-rate securities that regulators said the banks marketed to customers as safe.

The Securities and Exchange Commission formally approved the settlements with the two banking giants following preliminary deals that were reached in August. Securities regulators in Texas and New York also announced details of final agreements with the banks.