Princess Diana leaked information on Prince Charles to the News of the World in order to "take him on", the phone hacking trial has heard.
Former reporter Clive Goodman said Diana, who separated from the Prince of Wales in 1992 after 11 years of marriage, passed him information relating to the royal household and staff in an envelope sent to his office in Wapping.
The now-defunct tabloid's former royal editor, of Addlestone in Surrey, said: "She was looking for an ally to take him on - to show there were forces that would rage against him."
"She was going through a very, very difficult time," he told the Old Bailey on Thursday.
"She told me she wanted me to see the scale of her husband's staff and household, compared with others.
"She felt she was being swamped by people close to his household.
"She was looking for an ally to take him on - to show there were forces that would rage against him."
Goodman said he used "Green Books" and internal telephone directories (ITDs), containing contact numbers for royal staff and senior members of the household, for stories.
Asked by his counsel David Spens QC how he received them, he recalled how one Green Book was given to him in 1992 by the Princess of Wales.
He said: "That arrived at my office in Wapping with my name on it.
"She (Princess Diana) had a (good) relationship with several journalists - Richard Kay at the Daily Mail, Martin Bashir of Panorama."
Story continues after slideshow
Asked by Mr Spens if Diana gave a reason for leaking the details, Goodman said the royal had been going through "a very tough time" - only to be cut off by judge Mr Justice Saunders and asked to stick to what she had told him.
Goodman said he did not pay for the books.
Goodman, 56, denies two counts of conspiracy to commit misconduct in a public office.
Diana and Charles divorced in 1996. She was killed in a car crash in Paris a year later.