(Adds OTP's comment, updates markets)
* Court says exchange rate spread on fx loan was unfair, invalid
* Latest turn in legal saga on big pile of forex mortgages
* OTP says impact of ruling marginal
* Government has said would phase out fx mortgages
* Court says could make key broad ruling on June 16 (Adds OTP comment)
By Krisztina Than
BUDAPEST, June 3 Hungary's top court ruled on Tuesday that the exchange rate margin applied by OTP Bank on a foreign currency mortgage was unfair and invalid, a ruling that could guide government plans to tackle problem forex loans.
Prime Minister Viktor Orban, elected for a second term in April, is planning a new relief scheme for households whose Swiss franc and euro loans have become expensive to service.
Banks fear the programme will inflict new losses on the sector after years of heavy taxation and earlier tough government measures to help troubled borrowers.
Orban's government has said it will await a final ruling by the nation's top court, the Kuria, before it decides how to deal with about $15 billion worth of forex mortgages taken out by households mostly before the 2008 financial crisis.
The court said that ruling could be made on June 16.
But Tuesday's decision provides clues to what may be in store for the country's mostly foreign-owned banks.
The case was brought by a Hungarian borrower who complained OTP lent to him in Swiss francs at its buying exchange rate, while he had to repay the loan at the bank's selling rate.
The Kuria said this exchange rate spread - the difference between the rates at which the loan was disbursed and at which repayments are made - was unfair and invalid.
OTP shares fell after the ruling and were down 1.7 percent at 4,794 forints at 1327 GMT. The bank said in a statement that it would accept the ruling, which would not significantly affect the amount the borrower owes and would have no universal impact on other forex loans.
"Based on the decision of the Kuria, the parties will have to make settlement retroactively, which equals less than 1 percent of the total amount of the loan," OTP said.
The Kuria said OTP would have to apply the National Bank of Hungary's official exchange rate to both the amount disbursed and the repayments.
In its broad ruling expected on June 16, the court will address issues including the exchange rate margin and whether banks were transparent about unilateral changes to loan terms such as interest rate hikes. The ruling will set a firm precedent for similar cases brought to other courts in Hungary.
Akos Kuti, an analyst at brokerage Equilor, said that based on market estimates and his calculations, compensating all borrowers for the exchange rate spread could cost the financial sector up to 50 billion forints in a worst-case scenario.
"As for OTP and the banks, today's is not the decisive ruling, but the one which will affect the issue of contract modifications (interest rate changes)," Kuti said.
Low interest rates made foreign currency loans, mainly in the safe-haven Swiss franc, popular in Hungary before the 2008 financial crisis, but they turned sour as the Hungarian forint weakened, making the loans much more expensive to repay.
Many borrowers were pushed into default.
At 1327 GMT, the forint traded at 305.40 to the euro, weaker from around 304.50 shortly after the court ruling.
Hungary's largely foreign-owned banks have already lost more than a billion euros in a previous, 2011 relief scheme.
They include units of Belgium's KBC, Austria's Raiffeisen Bank, Erste Bank and Italy's UniCredit. (Reporting by Krisztina Than; Editing by Catherine Evans)