He is vain, secretive, paranoid and jealous, prone to leering at young women and making frequent sexist jokes – and that’s not the view of one of his many enemies, but of a friend who regards him sympathetically.

A damning picture of Julian Assange, the founder of WikiLeaks who is currently sheltering in the Ecuadorean embassy in London in a bid to avoid extradition to Sweden on rape charges, has emerged in a detailed account by his ghostwriter Andrew O’Hagan.

In a 45-page essay chronicling the collapse of a $2.5-million deal for Mr. Assange’s autobiography, Mr. O’Hagan, an award-winning novelist and non-fiction author, recounts how he spent months with the Australian computer hacker in an attempt to extract material for the book.

AP Photo/ Anthony Devlin, PoolIn June 2012 Julian Assange skipped out on a date with Swedish justice. Rather than comply with a British order that he go to the Scandinavian country for questioning about sex-crimes allegations, the WikiLeaks founder took refuge in Ecuador's London embassy.

But Mr. Assange, who was quite happy to reveal the secrets of governments around the world proved far more reluctant when it came to talking about his own past and private life.

“The man who put himself in charge of disclosing the world’s secrets simply couldn’t bear his own,” writes Mr. O’Hagan in the London Review of Books. “The story of his life mortified him and sent him scurrying for excuses. He didn’t want to do the book. He hadn’t from the beginning.

“He’d rather spend hours Googling himself than have his own say in the pages of his autobiography.”

In the end Mr. Assange’s publisher, Canongate, released its own version of the autobiography, after Mr. Assange allegedly failed to honour the terms of his contract. The book flopped, selling only 700 copies in its first week

During their time together, Mr. Assange behaved in front of Mr. O’Hagan like an egotistical tyrant interested more in his own self-publicity than in changing the world, Mr. O’Hagan writes. Worse still, he turned on his friends with increasing regularity, rather than focusing his anger on his enemies.

At one stage Mr. Assange allegedly described the Ecuadorean ambassador offering him diplomatic asylum as “mad,” “fat” and “ludicrous” for going on a diet because she did not like the photographs of herself in the press.

The WikiLeaks founder is also disparaging of his former ally Jemima Khan, who put up the surety for his bail before he broke its conditions by seeking refuge in the embassy. Mr. O’Hagan recounts: “He didn’t pause to ask why a loyal supporter might become aggrieved; when I raised it with him he simply made a horribly sexist remark.”

Earlier Mr. O’Hagan had watched as Mr. Assange leered at two 14-year-old girls as they walked past a café table at which they were sitting. Mr. O’Hagan writes how Mr. Assange thought they were “fine,” until he saw one was wearing braces.

Even Mr. Assange’s girlfriend, WikiLeaks researcher Sarah Harrison, grew increasingly frustrated at his behaviour during the weeks he spent on bail at Ellingham Hall, in Norfolk, the home of another of his guarantors, Vaughan Smith, the founder of the Frontline Club.

Ms. Harrison says of Mr. Assange: “He openly chats girls up and has his hands on their arse and goes nuts if I even talk to another guy. He’s like threatened to fire me a few times and always for crazy reasons. One of the times was literally because I had hugged another member of staff. Julian was like, ‘That’s so disrespectful to me’.”

Mr. O’Hagan, who had hoped to find an anti-authoritarian rebel figure worthy of admiration, says he came to regard Mr. Assange as someone who sacrificed the moral high-ground by attempting to evade trial over the rape charges.

Diana, Princess of Wales, was so serious about marrying the heart surgeon Hasnat Khan that she asked her friend Jemima Khan for advice on living in Pakistan.

The Princess made two trips to Pakistan to meet Hasnat Khan’s family, hoping they would grant their blessing for their son to marry her.

Mr Khan, with whom the Princess had a two-year-relationship, did not believe they would be able to make marriage work, and told her the only way they could live together would be if she moved to Pakistan, away from the world’s media.

REUTERS/Stringer Prince Charles and Princess Diana stand on the balcony of Buckingham Palace in London, following their wedding at St. Pauls Cathedral, in this June 29, 1981 file photo.

In an interview with Vanity Fair magazine, Jemima Khan, whose then husband Imran was a distant cousin of Hasnat Khan, described how the Princess turned to her for advice.

She said: “She came to visit me twice in Pakistan to help fund-raise for Imran’s hospital, but both times she also went to meet his family secretly to discuss the possibility of marriage to Hasnat.

“She wanted to know how hard it had been for me to adapt to life in Pakistan.”

But Mr Khan’s family did not approve of the idea. For a son “to marry an English girl is every conservative Pashtun mother’s worst nightmare”, said Jemima Khan.

Hasnat Khan told the inquest into the Princess’s death that he thought marrying her would have been a “ridiculous idea” and that he “told her that the only way I could see us having a vaguely normal life together would be if we went to Pakistan, as the press don’t bother you there”.

The Princess died in a car crash in 1997 alongside her then boyfriend, Dodi Fayed. Friends have said her relationship with Mr Fayed was designed to make Mr Khan jealous, hoping he would reconsider marriage after he ended their relationship.