The Swiss financial regulator broke bank secrecy law last year when it ordered UBS to hand over the files of nearly 300 clients to U.S. authorities, a Swiss court said on Friday.

Regulator FINMA decided on February 18 to allow UBS to hand over some client data to U.S. tax officials, weakening the country's strict bank secrecy rules in an effort to end a damaging probe into its biggest bank, which prompted clients to pull billions of francs from accounts and leave in droves.

Even though FINMA was in a difficult position because of the threat of charges against UBS AG, it should not have ordered unilaterally the passing on of data outside of a proper process of a request for official assistance, Switzerland's Federal Administrative Court said.

Zuercher Kantonalbank analyst Andreas Venditti said the ruling provided more clarity on FINMA's role in matters of bank secrecy, although the judgment could still be challenged.

The damage has already been done for UBS and maybe for the whole Swiss banking industry. But if this ruling means FINMA cannot act alone in future, it certainly helps, Venditti said.

UBS shares extended earlier gains after the ruling was published, ending the session up 3.8 percent at 17.21 Swiss francs. The DJ Stoxx European banking sector index was up 1.24 percent.

UBS agreed last February to pay a $780 million fine and disclose the identity of some clients after U.S. investigators accused it of helping wealthy Americans to dodge taxes.

At the time, Swiss Finance Minister Hans-Rudolf Merz defended the move, saying UBS had no choice but to settle the case to avoid criminal charges that could have threatened its existence and undermined Switzerland's economy.

FINMA's decision was a prelude to the Swiss government bowing to international pressure on tax havens and agreeing to soften its cherished bank secrecy laws in March, a competitive advantage for the Alpine country's banks.

UP TO UBS CLIENTS TO RESPOND

The court said it was now up to clients to decide what further action they take.

Lawyers now have to examine it and decide whether their clients derive claims from it, a court spokeswoman said.

Andreas Rued, a lawyer representing some of the clients in the complaint against FINMA, said it was too early to say what action they might take as FINMA could still lodge an appeal at the high court.

The damage has already been done and now it's only a matter of what compensation clients might receive. It will not compensate for any criminal charges in the United States and there has been tremendous damage to the Swiss banking industry's reputation internationally, said the lawyer at Rued Winkler Partner AG in Zurich.

UBS declined to comment, while FINMA said it would look closely at the decision and decide whether to appeal.

The cabinet had taken note of the judgment and would discuss the issue at its next meeting on Wednesday, Swiss government spokesman Andre Simonazzi said.

The court said overtures by the Swiss cabinet and parliament to FINMA to do everything in its power to prevent possible prosecution of UBS by U.S. authorities did not go as far of telling FINMA to have UBS hand over client accounts.

It said FINMA had incorrectly based its decision to allow UBS to hand over the data on Articles 25 and 26 of Switzerland's banking law, which permit bank secrecy to be lifted in special cases to prevent the threat of insolvency to a bank.

Canada's revenue minister, Jean-Pierre Blackburn, said on Friday the country would formally ask France to share information it has on Canadians with Swiss bank accounts to help Ottawa crack down on tax dodgers, and that the Swiss court's judgment on FINMA was not good news.

In August, the Swiss government struck a deal to hand over details of 4,450 UBS bank accounts to end the long-running U.S. investigation into the bank.

That settlement was based on an existing double taxation agreement between the two countries and is unaffected by Friday's ruling.

(Editing by Karen Foster)