The day Julian Assange threatened to sue The Guardian over the US embassy cables story

The WikiLeaks US embassy cables revelations caused a world-wide sensation. But the story behind their publication turns out to be just as sensational too.

It transpires that the partnership between the WikiLeaks founder Julian Assange and The Guardian was anything but straightforward.

According to a Vanity Fair article by Sarah Ellison, there were rows, legal threats and a series of shocks before the newspaper was able to publish what she calls "one of the greatest journalistic scoops of the last 30 years."

She has reconstructed a blow-by-blow account of the twists and turns of the strained relationship between The Guardian - and other papers, including the New York Times - and Assange.

He emerges as an enigmatic, erratic and high-handed individual whose changes of mind and mood bedevilled the process of publishing the documents.

Assange is now under police bail in Britain, facing extradition to Sweden for questioning about claims of sexual assault. But Ellison's report sticks only to his dealings with The Guardian.

She tells how The Guardian's Nick Davies and Ian Traynor made the original contact with Assange in June last year. From that sprang the first revelatory cache of military logs of the war in Afghanistan.

The Guardian, having brought the New York Times on board, then got its first inkling of the difficulties it might have with Assange. Without consulting the paper, Assange arranged for Germany's Der Spiegel to join the partnership.

It also became clear that there was a major difference between the ethos of the newspapers and that of WikiLeaks. While the papers' editors were not prepared to publish anything that might lead to reprisals, WikiLeaks was happy to allow the names of Afghan civilians to be posted on its website.

Assange did not favour redaction. Ellison quotes The Guardian's investigations editor, David Leigh, as saying:

"We were starting from: 'Here's a document. How much of it shall we print?' Whereas Julian's ideology was, 'I shall dump everything out and then you have to try and persuade me to cross a few things out.' We were coming at it from opposite poles."

By this time, WikiLeaks colleagues noted that Assange was "becoming increasingly autocratic and dismissive." So did The Guardian.

Just before publication of the Afghan logs, a furious Davies was shocked to discover that Assange had unilaterally given the database to Channel 4.

Next came the war logs relating to the war in Iraq, and Assange sprang yet another surprise on The Guardian by demanding that the Bureau of Investigative Journalism should have access to the material.

This meant a delay in publishing. Leigh agreed to that, but only if Assange would gave the paper another batch of documents - the so-called "package three" - which was the highly sensitive US embassy cables.

According to Leigh, Assange told him: "You can have package three tonight, but you have to give me a letter signed by the Guardian editor saying you won't publish package three until I say so." Assange got his letter

Meanwhile, there were continuing problems of WikiLeaks's refusal to redact as The Guardian started its Iraq war logs publication on 23 October amid what Ellison refers to as "a growing sense of unease among the media outlets, both with one another and with Assange."

The NY Times went so far as to publish a critical profile of Assange in which it quoted his anonymous former colleagues as speaking of his "erratic and imperious behaviour, and a nearly delusional grandeur."

The Guardian then discovered that a former WikiLeaks volunteer had leaked "package three" to the freelance journalist, and freedom-of-information campaigner, Heather Brooke.

Leigh, having invited Brooke to join The Guardian team, realised that by obtaining the data from a source other than Assange, the paper was released from its promise to wait for Assange's green light to publish.

Leigh passed on the documents to Der Spiegel and the NY Times, and the three titles were poised to publish on 8 November. With seven days to go, Assange and his lawyer stormed into the office of Guardian editor Alan Rusbridger and threatened to sue.

Rusbridger, Leigh and executives from Der Spiegel then spent a marathon session with Assange, his lawyer and another WikiLeaks member, Kristin Hrafnsson, before "an uneasy calm" was restored.

Ellison writes of that crucial meeting in detail:

"Assange was pallid and sweaty, his thin frame racked by a cough that had been plaguing him for weeks. He was also angry, and his message was simple: he would sue the newspaper if it went ahead and published stories based on the quarter of a million documents that he had handed over to The Guardian just three months earlier...

"Rusbridger somehow kept all parties at the table — a process involving a great deal of coffee followed by a great deal of wine. Ultimately, he agreed to a further delay, allowing Assange time to bring in other media partners, this time France's Le Monde and Spain's El País."

In the end, The Guardian and the other four papers were able to publish, thus sparking a hugely critical response from the US administration, which is seeking ways to prosecute Assange.

But, as we have seen, it had been a rocky road for The Guardian way before it faced up to that controversy. Ellison writes:

"When I asked Rusbridger if he had any regrets about the way his paper handled the cables or the way it worked with WikiLeaks, he said, "No," but his response was so tentative that it seemed to reveal how fragile the project was in his mind.

"I think given the complexity of it all, touch wood, as I speak at the moment, it is remarkable it has gone so well. Given all the tensions that were built into it, it would have been surprising to get out of it without some friction, but we negotiated it all quite well."