The United States and Swiss bank UBS AG said on Friday they had agreed to settle a dispute over tax evasion and bank secrecy, heading off a showdown that had threatened relations between the two countries.

The United States had insisted that Switzerland's best-known bank reveal the names of thousands of wealthy Americans suspected of using UBS to evade taxes. The Swiss government had fiercely resisted what it portrayed as an assault on its sovereign bank secrecy laws.

I'm reporting to the court that the parties have reached an agreement in principle on the major issues, U.S. Justice Department attorney Stuart Gibson said in a conference call with Florida federal court Judge Alan Gold.

There are some other issues that need to get resolved, and we expect to be able to resolve them during the coming week, Gibson said.

He gave no details of the settlement, but told Gold a final signed accord should be ready in time for a pretrial status conference in the case that the judge set for Friday, August 7.

WASHINGTON, BERNE WELCOME DEAL

The deal has forestalled a trial against UBS that was scheduled to begin on Monday in Miami, Florida. Gold tentatively reset the trial date for August 10, but it would be called off if a final agreement is signed.

UBS shares were up 7.03 percent, or 97 cents, at $14.76 in afternoon trading.

Before meeting in Washington on Friday, U.S. Secretary of State Hillary Clinton and her Swiss counterpart, Micheline Calmy-Rey, said they were pleased with the preliminary agreement.

Swiss Foreign Ministry spokesman Lars Knuchel said the settlement was a breakthrough in Swiss-American relations.

The simple fact that two delegations from both governments have now in principle reached an agreement is a good example for the overall good relationship, he said after the meeting.

U.S. authorities have been trying to force UBS to disclose the identities of as many as 52,000 U.S. holders of secret Swiss accounts.

The U.S. investigation into UBS grabbed media attention in June 2008 when Bradley Birkenfeld, a former UBS banker, disclosed in a federal court in Fort Lauderdale, Florida, that he once smuggled a client's diamonds into the United States in a toothpaste tube to avoid detection by U.S. authorities.

Five months later, Raoul Weil, a Swiss citizen who was then head of UBS AG's wealth management business, was charged with conspiring to help thousands of Americans hide $20 billion in assets from U.S. tax authorities.

Weil, who has since left UBS but denies any criminal wrongdoing, is considered a fugitive from U.S. justice. A U.S. spokesman for Weil's lawyer said Weil was in Switzerland.

NAMES RATHER THAN MONEY

In February, UBS agreed to pay $780 million to settle criminal charges it was facing under a separate but related tax dispute. It agreed to hand over data related to around 250 U.S. clients who had secret Swiss accounts and promised to close its offshore business to U.S. clients.

The Swiss government stretched its bank laws to the limit to pass along the data without formally violating its laws, but tax lawyers said the case was a serious hit to traditional Swiss bank secrecy.

Swiss media have reported that UBS was likely to pay a multibillion-dollar fine as part of any agreement. But a U.S. government source who has followed the case closely downplayed talk of a financial penalty.

I don't think there's going to be a fine component at all. I don't think that was ever really on the table, said the source, who spoke on condition of anonymity.

He said the settlement was likely to lead to far less than 52,000 UBS client names being handed over to U.S. authorities, but would involve a sizable transfer of data by the Swiss bank involving some of its biggest U.S. customers.

Joann Weiner, a former Treasury Department tax official, said if the U.S. Internal Revenue Service got roughly 10,000 client names from UBS it would be a pretty good deal.

It was clear the IRS did not want to settle, but there are more people than the tax guys at the table, she said, noting diplomats were believed to be involved in the settlement.

The U.S. case against UBS is part of a global effort by the world's most developed countries to clamp down on tax evasion.

Lawyers and tax experts say the United States will continue pushing foreign banks to ensure their American clients pay the taxes they owe back home.

I think it wants to set a precedent that will enable it to go after other Swiss banks that have a footprint in the U.S., said Scott Michel, a Washington lawyer who advises individuals and companies on tax issues.

So the IRS can use whatever information template is being used with UBS, he said.

Lawyers expect some European countries to follow the United States' lead in cracking down on offshore banking.

(Reporting by Tom Brown; Additional reporting by Jim Loney in Miami, Sue Pleming, Deborah Charles and Kim Dixon in Washington; Editing by Pascal Fletcher, Toni Reinhold)