Tony Blair told Rebekah Brooks he was thinking of her and offered to help her in the wake of the Milly Dowler phone hacking allegations, the Old Bailey has heard.
The former News of the World editor said she was sent a message from the ex-prime minister, saying: "Let me know if there's anything I can help you with.
"Thinking of you. I've been through things like this."
TOP STORIES TODAY
Brooks replied to the message, sent on July 5 2011: "Thank you, I know what's it's like. GB (Gordon Brown) pals getting their own back. Rupert and James (Murdoch) have been brilliant.
"Hopefully even in this climate the truth will out."
Brooks, 45, said she also received death threats in the wake of the allegations.
"The allegations were, I think, met with universal revulsion and I was the central figure of that," she said.
Under questioning from her lawyer Jonathan Laidlaw QC, Brooks was asked about the events of July 2011, when the Guardian broke the "horrific" story.
Brooks, who was by that time chief executive of News International, told jurors that she and her colleagues were horrified by the allegations and desperately tried to find out if they were true.
She said that as the story made headlines around the world, "we were completely at a loss and all over the place really, trying to find out what was true and what wasn't".
Brooks, of Churchill, Oxfordshire, denies conspiring to hack phones, conspiring to commit misconduct in public office and conspiring to cover up evidence to pervert the course of justice.
Jurors were also read messages of support that Brooks received from former Mirror editor Piers Morgan.
"When it rains, it f***ing pours. Grit your teeth and stay strong," Morgan wrote.
Jurors heard that Brooks replied: "Can't believe any reporter would do that. Must have been (Glenn) Mulcaire."
Morgan then wrote back: "If it wasn't a staffer you've got to get it out there fast. Lots of fury building on internet."
There was laughter in the court room as Brooks said Morgan was an "avid tweeter".
"I was going to say twit," she added.
Mr Laidlaw interrupted: "I'm going to save you digging deeper."
A message from Mike Dunn, who was sports editor of the News of the World and the Sun under Brooks' editorship, was also read out.
He wrote: "I've known you long enough to know that it's completely impossible for you to have had any hint of these activities at the News of the World.
"You remain the greatest editor and journalist I've ever known. I've always felt privileged to work alongside you, you've done absolutely nothing wrong.
"It is totally alien to your character and soul."
Brooks said it was believed that whoever had hacked Milly's phone was not a staff member at the paper.
"Obviously the accusation of Milly Dowler's phone in itself was terrible, but it was the deletion of the messages, the false hope, that was rightly sparking fury," she said.
The allegation that voicemails had been deleted, and therefore given Milly's parents the impression she could still be alive, was later found to be untrue.
Jurors heard that in a message to a friend, Brooks said she felt there was a "witch hunt" against her.
She said that she and senior colleagues had first discussed closing the News of the World in June 2011 due to the mounting number of civil liability cases brought against it by celebrities.
The final edition of the paper was published just days after the Milly story broke, on July 10. Brooks went on to resign on July 15. She told jurors: "I felt it was the right thing to do."
Brooks said that, as time went on, she suspected she would be arrested and feared she would be detained by police in a dawn raid at her home, explaining that this was why some of the messages she was sent related to her staying elsewhere.
Mr Laidlaw said he wanted to turn to Count 6 on the indictment, an offence of conspiring to cover up evidence to pervert the course of justice between July 6 and 9 2011.
"Is there any truth in that?" he asked.
"No, absolutely not," Brooks replied.
Mr Laidlaw asked Brooks to describe Cheryl Carter, 49, her co-defendant on that charge, who worked as her personal assistant for 16 years.
Brooks described her as an "amazing friend" and "brilliant PA" who acted as her "eyes and ears of the newsroom".
But asked to talk about her downsides, Brook admitted that mother-of-two Carter could be "scatty and forgetful".
There was laughter in the courtroom as she told how, on one occasion, Carter told Rupert Murdoch that Brooks had gone to furniture store MFI, when she had been instructed to tell him she was attending an important meeting at MI5.
"I was petrified that Rupert was going to hang me," Brooks said.
Mr Laidlaw said: "The prosecution asserts that you recruited Cheryl to pervert the course of justice. Is she the sort of candidate that you would cast for that role?"
Brooks replied: "No, but also because she is an incredibly decent, hard-working woman. It's not just because she's scatty, as she is, but because she's true."
Brooks said Carter and her other personal assistant were "constantly looking for places to store bulky materials" as the number of notepads and other materials she had gone through over the years took up lots of space.
Asked if she knew seven boxes were removed from the News International archives, Brooks said: "Absolutely not."
Asked if she had any knowledge of the boxes, Brooks replied: "No."
Jurors also heard correspondence between Brooks and her mother, who was very fearful for her safety during the period and urged her not to go outside alone.
"Mum, I have more security than the Prime Minister," Brooks replied.
All seven defendants deny the charges against them.