(Adds stock market retreat, details of case)
BRASILIA May 21 Brazil's second-highest court dealt a blow to the banking industry on Wednesday by deciding in favor of depositors in a landmark case involving disputed compensation for savings dating back two decades.
The ruling hit bank shares on Sao Paulo's stock market and pushed its Bovespa index into negative territory.
The Supreme Court of Justice (STJ) decided against the banks in setting the time frame of lawsuits claiming that banks failed to pay fair interest on deposits between 1987 and 1992, when hyperinflation led the government to peg savings rates to a number of consumer price indexes.
Depositors argued that additional interest should be calculated from the date the first class actions were filed in the early 1990s and not when individual claims were made starting in 2010, as the banks sought.
Brazil's highest court, the Federal Supreme Court, still has to rule on the constitutional issues of the case and decide whether the banks will have to pay compensation or not.
Banks could end up having to pay up to 341 billion reais ($148 billion) in compensation as a result of the ruling, banking industry group Febraban said at the start of the year.
That could significantly reduce the capital of the biggest banks and further trip up a flagging Brazilian economy.
Brazilian bank stocks fell on Wednesday, with Itaú Unibanco Holding SA, the nation's largest lender by market value, closing down 2.13 percent. Rival Banco Bradesco SA ended down 2.54 percent.
State-run Banco do Brasil SA, which analysts said would be the most affected in the event of an adverse ruling, fell 7.25 percent at the close. (Reporting by Anthony Boadle; Editing by Chris Reese)