A confidential settlement has been reached between the BBC, the Guardian and law firm Appleby over the reporting of leaked documents detailing offshore tax-avoidance schemes.

Appleby began legal action after details from the documents, known as the Paradise Papers, were published.

It said it wanted to know which of its confidential documents had been taken.

The Guardian and BBC said the reports were in the public interest but did not give more detail about the settlement.

Panorama led research for the BBC as part of a global investigation involving nearly 100 other media organisations in 67 countries, after the records were passed to German newspaper Süddeutsche Zeitung.

The BBC does not know the identity of the source. Appleby says the data was taken by hackers.

The leak of financial documents revealed how the powerful and ultra-wealthy secretly invest cash in offshore tax havens.

They contained details about investments made by the Queen's private estate, a tax avoidance scheme used by three stars of BBC sitcom Mrs Brown's Boys and also showed that Formula 1 champion Lewis Hamilton avoided tax on his £16.5m luxury jet.

About half of the 13.4m leaked documents were from Appleby, one of the world's largest providers of offshore legal services.

In a joint statement, Appleby, the Guardian and the BBC said they have "resolved their differences" in relation to the breach of confidence claim.

It said: "Without compromising their journalistic integrity or ability to continue to do public interest journalism, the Guardian and the BBC have assisted Appleby by explaining which of the company's documents may have been used to underpin their journalism.

"It is now clear that the vast majority of documents that were of interest in the Paradise Papers investigation related to the fiduciary business that is no longer owned by Appleby and so were not legally privileged documents."

Michael O'Connell, group managing partner of Appleby, said: "From the outset we wanted to be able to explain to our clients and colleagues what information of theirs had been stolen. That was our duty.

"As a result of this legal action we are well on our way to achieving our objectives."

The Guardian said the reporting of the Paradise Papers was investigative journalism that had raised important issues.

The BBC said it welcomed the settlement as it "preserves our ability to carry out investigative journalism in the public interest".