Harry Potter author JK Rowling has accepted a "substantial donation to charity" from the law firm that breached her confidentiality by revealing that she was writing under the pseudonym Robert Galbraith.
The author brought legal proceedings at London's High Court against Chris Gossage, a partner at Russells, and a friend of his, Judith Callegari.
Ms Rowling was revealed as the author of crime novel The Cuckoo's Calling by a Sunday newspaper earlier this month.
Law firm Russells contacted Ms Rowling's agent a few days after the author's pseudonym was revealed in the Sunday Times and disclosed that it was Mr Gossage who had disclosed the confidential information to his friend, Ms Callegari, who then communicated it to a journalist via Twitter.
Ms Rowling's solicitor Jenny Afia told the court her client, who was not present during proceedings, "has been left dismayed and distressed by such a fundamental betrayal of her trust".
Both Mr Gossage, Ms Callegari and Russells apologised.
Russells agreed to reimburse Ms Rowling's legal costs and to make a "substantial donation", by way of damages, to the Soldiers' Charity, formerly known as the Army Benevolent Fund.
The Cuckoo's Calling, a 450 page novel that has been likened to the works of prolific crime fiction writers Ruth Rendell and PD James, is a whodunit centred around war veteran-turned- private- investigator Cormoran Strike.
It garnered a number of positive reviews when first published, before Ms Rowling was unmasked as its author.
A statement issued today on the author's behalf said that all global net royalties which would otherwise have been paid to her from sales of The Cuckoo's Calling would be donated to The Soldiers' Charity for a period of three years, dating from 14 July - the day that Galbraith's identity was made known.
She said: "This donation is being made to The Soldiers' Charity partly as a thank you to the Army people who helped me with research, but also because writing a hero who is a veteran has given me an even greater appreciation and understanding of exactly how much this charity does for ex-servicemen and their families, and how much that support is needed.
"I always intended to give The Soldiers' Charity a donation out of Robert's royalties but I had not anticipated him making the bestseller list a mere three months after publication - indeed, I had not counted on him ever being there! "
Major General Martin Rutledge, chief executive of the charity, said: "We are absolutely thrilled by the extraordinary generosity of JK Rowling who is such an internationally renowned author.
"This donation will make a huge difference to the lives of thousands of soldiers, former soldiers and their families who are in real need.
"Her tremendous show of support for The Soldiers' Charity will help to remind people of the many sacrifices made by our soldiers, long after any news of Afghanistan has left the front page."
Since the Sunday Times report naming her the novel has received a considerable boost in sales with Nielsen BookScan data revealing that 17,662 hardback copies of the novel were sold between 14 and 20 July, up from just 43 copies the previous week.
Ms Afia said only a handful of trusted advisers, family and friends were aware of Galbraith's true identity until it was published by a Sunday newspaper.
She said: "The claimant was angry and distressed that her confidences had been betrayed and this was very much aggravated by repeated speculation that the leak had, in fact, been a carefully co-ordinated publicity stunt by her, her agent and her publishers designed to increase sales.
"The claimant has been left dismayed and distressed by such a fundamental betrayal of trust.
"As a reflection of their regret for breach of the claimant's confidence, including frustrating the claimant's ability to continue to write anonymously under the name Robert Galbraith, the defendants are here today to apologise publicly to the claimant."
Writing on website Robert-Galbraith.com Ms Rowling explained her decision to publish under a pseudonym: “I was yearning to go back to the beginning of a writing career in this new genre, to work without hype or expectation and to receive totally unvarnished feedback. It was a fantastic experience and I only wish it could have gone on a little longer.”
She has denied that revealing the book’s true author was part of an “elaborate marketing campaign to help boost sales”.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies