UBS AG has been sued by older investors who claimed it steered them into mutual funds that invested heavily in Puerto Rico bonds, costing much of their life savings and causing billions of dollars of losses because of the commonwealth's fiscal woes.

According to a complaint made public on Tuesday, UBS viewed the 23 closed-end funds as "cash cows," generating tens of millions of dollars of extra fees by stuffing them with Puerto Rico government bonds it underwrote, and which it should have known were risky given the economy's instability.

The complaint filed in Manhattan federal court said UBS exacerbated the problem by using leverage in the funds, and encouraging clients who needed to preserve capital ahead of retirement to instead take out $500 million of costly loans to boost their investments in the funds.

"This combination of high leverage and exposure to high-risk debt securities made the funds ticking time bombs," and by March the funds had lost more than half their value, it said.

Puerto Rico's economy has been in or near recession for eight years, and its debt was cut to junk status this year by the three major U.S. credit rating agencies.

Gov. Alejandro Garcia Padilla last week announced plans to cut $1.4 billion of public spending in an effort to balance the commonwealth's budget.

UBS spokeswoman Megan Stinson had no immediate comment on the lawsuit.

Popular Inc, the parent of Banco Popular, is also a defendant with regard to its alleged role in nine of the funds. Teruca Rullán, a spokeswoman, had no immediate comment.

The lawsuit is dated May 5 and seeks class-action status covering thousands of people mainly in their 50s and older, Daniel Berger, a partner at Grant & Eisenhofer who represents the plaintiffs, said in an interview.

"UBS was in a superior position to know about the risks of investing in these funds," Berger said. "UBS took advantage of its clients by putting them in mutual funds that it portrayed as safe, secure and not risky. Under Puerto Rico law, it had a fiduciary duty to act in its clients' best interest, not UBS' best interest, and it didn't."

The complaint said UBS' client relationship agreement required that the litigation be pursued in New York.

The case is Fernandez et al v. UBS AG et al, U.S. District Court, Southern District of New York, No. 14-03252