It led to claims that the revelation had been a marketing ploy to boost interest in The Cuckoo's Calling, which tells the story of Cormoran Strike, a war veteran turned private eye, who is investigating the death of a model.
Her publishers have now reprinted 140,000 copies of her crime debut to meet demand.
But Miss Rowling, 47, has spent the last four days trying to discover how her secret had been passed to Mrs Callegari, a woman she has never met.
Now the legal firm, Russells, has apologised unreservedly after one of its partners, Chris Gossage, was identified as the source of the leak.
He had revealed the true identity of Robert Galbraith to Mrs Callegari - his wife's best friend - during a private conversation.
Miss Rowling said in a statement: "I have today discovered how the leak about Robert's true identity occurred.
"A tiny number of people knew my pseudonym and it has not been pleasant to wonder for days how a woman whom I had never heard of prior to Sunday night could have found out something that many of my oldest friends did not know.
"To say that I am disappointed is an understatement. I had assumed that I could expect total confidentiality from Russells, a reputable professional firm, and I feel very angry that my trust turned out to be misplaced."
The London law firm said in a statement: "We, Russells Solicitors, apologise unreservedly for the disclosure caused by one of our partners, Chris Gossage, in revealing to his wife's best friend, Judith Callegari, during a private conversation that the true identity of Robert Galbraith was in fact JK Rowling.
"Whilst accepting his own culpability, the disclosure was made in confidence to someone he trusted implicitly.
"On becoming aware of the circumstances, we immediately notified JK Rowling's agent.
"We can confirm that this leak was not part of any marketing plan and that neither JK Rowling, her agent nor publishers were in any way involved."
The publisher of The Cuckoo's Calling had claimed it was written by a former plain clothes Royal Military Police investigator using the pen-name of Galbraith.
But literary sleuths would have noticed that the novice writer shared an agent with Miss Rowling. And the novel was published by Sphere, part of publisher Little, Brown Book Group, which released Miss Rowling's first book for adults, The Casual Vacancy, last year.
Readers had noted on social networking sites how well the 'male' author had described women's clothes.
The Cuckoo's Calling had received rave reviews, with Val McDermid, author of The Wire In The Blood, saying it reminded her "why I fell in love with crime writing in the first place".
Miss Rowling had said it had been wonderful to publish for once without hype or expectation and to get feedback under a different name even if that meant some publishers rejected her work.
Last night there was no answer from the intercom at Mrs Callegari's large detached home in Claygate, Surrey. Mr Gossage was not available for comment.
Miss Rowling has hinted that a sequel will appear to the crime novel she wrote as Robert Galbraith. She wrote: "Robert fully intends to keep writing the series, although he will probably continue to turn down personal appearances."
And despite her anger she has even signed a few copies of her detective novel as Robert Galbraith, according to her publicist Nicky Stonehill.
When she began publishing her Harry Potter novels Miss Rowling decided to use her initials rather than her first name, Joanne, because she feared that boys would not want to read a book by a woman author.
- Daily Mail