US secretary of state Hillary Clinton addresses reporters the morning after the publication of the 250,000 embassy cables by the Guardian and its media partners. Photograph: Win McNamee/Getty Images

Three men were in the Belgian hotel courtyard cafe, ordering coffee after coffee. They had been arguing for six hours through the summer afternoon, with a break to eat a little pasta, and evening had fallen. Eventually, the tallest of the three picked up a cheap yellow napkin, laid it on the flimsy modern cafe table and started to scribble. Ian Traynor, the Guardian’s European editor, recalls: “Julian [Assange] whipped out this mini-laptop, opened it up and did something on his computer. He picked up a napkin and said, ‘OK you’ve got it.’ “We said: ‘Got what?’ “He said: ‘You’ve got the whole file. The password is this napkin.'”

Traynor adds: “I was stunned. We were expecting further, very long negotiations and conditions. This was instant. It was an act of faith.” Assange had insouciantly circled several words and the logo on the Hotel Leopold napkin, adding the phrase “no spaces”.

This was the password. In the corner he scrawled three simple letters, GPG – a reference to the encryption system he was using for a temporary website. The napkin was a perfect touch, worthy of a John le Carré thriller. Nick Davies stuffed the napkin in his case together with his dirty shirts. Back in England, the yellow square was reverently lodged in his study, next to a pile of reporters’ notepads and a jumble of books. “I’m thinking of framing it,” he says.

This encounter in Brussels – the fruit of Davies’ eager pursuit of Assange would result in an extraordinary, if sometimes strained, partnership between a mainstream newspaper and WikiLeaks: a new model of co-operation aimed at publishing the world’s biggest leak.

Weight of endeavour

Less than two months later, David Leigh sat in a rented cottage in the Scottish Highlands. The Guardian’s investigations editor had originally planned to spend his annual summer holiday with his wife, hill-walking in the Grampians. But the summits of Dreish, Mayar, Lochnagar and Cat Law went unconquered. He sat transfixed at his desk instead, while the sun rose and set daily on the heather-covered hills outside. On the tiny silver Hewlett Packard memory stick plugged into his MacBook were the full texts of more than 250,000 diplomatic cables. To search through them was maddening, tiring – and utterly compelling.

It had been a struggle to prise these documents from Assange back in London. There were repeated pilgrimages to the mews house belonging to Vaughan Smith’s Frontline Club near Paddington station before Assange reluctantly turned them over. He was keeping the three news organisations – the Guardian, the New York Times and Der Spiegel – dangling, despite his original agreement to deliver all the material for publication. He had willingly passed on the less important war logs from Afghanistan and Iraq, but talked of how he would use his power to withhold the cables in order to “discipline” the mainstream media.

The atmosphere had become even more problematic since Davies personally broke off relations in the summer, after Assange breached the original compact, as Davies saw it, by going behind his back and sharing the Afghanistan war logs with the Guardian’s TV rivals at Channel 4, taking with him all the knowledge acquired by privileged visits to the Guardian’s research room. Davies at the time said he felt betrayed: Assange simply insisted there had never been a deal.

Now, isolated up in the Highlands, with only hares and buzzards for company, Leigh braced himself to venture into the dangerous contents of the memory stick. Obviously, there was no way he, or any other human, could read through a quarter of a million cables. Its sheer bulk was overwhelming. If the tiny memory stick containing the cables had been a set of printed texts, it would have made up a library containing more than 2,000 sizeable books.

Leigh began his experiments by searching for the word “Megrahi”. The resulting picture that emerged of US diplomatic dealings with Libya was richly textured and fascinating. It showed a superpower at work: cajoling, fixing, eavesdropping, manoeuvring and sometimes bullying. It also showed the dismayingly crazed attitudes of a foreign ruler possessing both nuclear ambitions and a lucrative reservoir of the world’s oil – a truth which his own subjects would rarely be allowed to see. And, from the point of view of a domestic British reporter, it showed how limited the options open to the UK seemed to be despite its pretensions to punch above its weight in the world.

It was clear that America’s secret diplomatic dealings over Libya were revelatory – not only newsworthy, but also important. This was a picture of the world seen through a much less scrambled prism than usual. And there were more than another 100 countries to go.

Betrayal claims

In early November, the three partner publications decided it was time for a meeting with Assange. Everything was threatening to get rather messy. The embattled WikiLeaks founder now wanted the Americans frozen out of the much-delayed deal to publish the diplomatic cables jointly – a punishment, so it was said, for a recent profile of him by the New York Times veteran London correspondent John F Burns. Assange had intensely disliked it.

The British were anxious about the fact that another copy of the cables had apparently fallen into the hands of Heather Brooke, a London-based American journalist and freedom of information activist. The Germans were worried that things could get acrimonious all round unless the editors held a clear-the-air meeting with what was left of WikiLeaks.

Assange had barely sat down before he started angrily denouncing the Guardian. Did the New York Times have the cables? How did they have them? Who had given them to them? This was a breach of trust. His voice was raised and angry. “We are getting the feeling that a large organisation is trying to find ways to step around a gentlemen’s agreement. We’re feeling a bit unhappy.”

Alan Rusbridger, the Guardian’s editor, responded that things had changed. The cables had fallen into the hands of Brooke. Things would soon move out of our control unless they decided to act more quickly. Assange didn’t look well.

“They ran a front-page story – the front page! – a front-page story which was just a sleazy hit job against me personally, and other parts of the organisation, and based upon falsehoods.” The Burns profile had dwelt, among other things, on the continuing police investigation into the Swedish sex allegations.

Burns had written that WikiLeaks staff had turned against Assange in the scandal’s wake. They complained, he wrote, that their founder’s “growing celebrity has been matched by an increasingly dictatorial, eccentric and capricious style”.

Assange had another startling announcement. He wanted to involve other newspapers from the “Romance languages”, to broaden the geopolitical impact. He mentioned El País and Le Monde. The others in the room looked at each other. This was going to double the complexities of an arrangement that was difficult enough to co-ordinate. But by now there was at least a negotiation about the means to go forward.

Asked under what conditions he would now collaborate with the Americans, Assange said he would only consider it if the paper agreed to run no more negative material about him and offered him a right to reply to the Burns piece with equal prominence. As the meeting dragged beyond midnight, it was decided that Rusbridger would ring Bill Keller, the New York Times executive editor.

Rusbridger returned to the room and conveyed Keller’s message. Assange should write a letter, and there were no plans for sleazy hit pieces.

As he feared, Assange reacted furiously, saying this was not sufficient and that all bets were off. He announced that both the New York Times and Guardian themselves were now to be thrown out of the deal.

It was Der Spiegel’s turn to speak, deliberately and firmly. The three publications were tied together, said its editor, Georg Mascolo. If Assange was cutting out the other two then the German publication was also out.

It was now nearly 1.30am. The discussion was going nowhere, so Rusbridger turned to Assange and summarised the position. “As I see it you have three options. One, we reach no deal; two, you try and substitute the Washington Post for the New York Times; three, you do a deal with us three.

“One and two don’t work because you’ve lost control of the material. That’s just going to result in chaos.

“So I can’t see that you have any option but three. You’re going to have to continue with us. And that’s good. We have been good partners. We have treated the material responsibly. We’ve thrown huge resources at it. We’re good at working together, we like each other. We’ve communicated well with your lot. It’s gone well. Why on earth throw it away?”

If Assange was convinced, he wasn’t going to show it. Not that night, anyway. The next day Rusbridger sent Assange’s lawyer, Mark Stephens, a memo setting out the offer, which would see publication begin on 29 November, with exclusivity to the core partner publications, now numbering five, until a week after Christmas.

Within 24 hours Stephens rang back to say Assange had OK’d the deal. Five of the world’s most reputable publications were now committed to selecting, redacting and publishing, on an unprecedented scale, the secret leaked diplomatic dispatches of a superpower. It was a project of astonishing boldness, which stood a chance of redefining journalism in the internet age.

Swiss spoiler

On the morning of Sunday 28 November, few were around at sleepy Badischer Bahnhof. The Basel station sits precisely on the border between Germany and Switzerland. It is a textbook example of European co-operation – with the Germans providing the trains, and the Swiss running the cafes and newspaper kiosks. This morning, however, the station would become briefly notorious for something else: a gigantic foul-up.

Early in the morning, a van rolled in, bearing 40 copies of Der Spiegel. The weekly German news magazine normally starts distributing copies to newsagents over the weekend, but on this occasion Spiegel was supposed to have held all copies of its edition back. The international release of the US embassy cables had been painstakingly co-ordinated for 21.30 GMT that evening. The Guardian, New York Times, El País and Le Monde were all waiting anxiously to push the button on the world’s biggest leak. Everyone knew the script.

But the gods of news had decided to do things differently. At around 11.30am Christian Heeb, editor-in-chief of Radio Basel, discovered a copy of Der Spiegel at the station. The front cover was nothing less than sensational: “Revealed: How America Sees the World … the secret dispatches of the US foreign ministry.” Against a red background was a photo-gallery of world leaders, each accompanied by a quotation culled from the US cables. Angela Merkel, Germany’s increasingly unpopular chancellor, was “risk-averse and rarely creative”. Guido Westerwelle, Merkel’s foreign minister, was “aggressive”. Then there were the others. Vladimir Putin? “Alpha dog”. Silvio Berlusconi? “Wild parties”. Mahmoud Ahmadinejad? “Hitler”. Next to Libya’s Muammar Gaddafi were the tantalising words: “Luxuriant blonde nurse”.

Heeb’s station started to broadcast the news, saying a few early copies had become available at the station. It was at this point that a Twitter user called Freelancer_09 decided to check out the prospect for himself. He managed to obtain one of the last two or three copies of the rogue Spiegel batch, just as panicked executives at the magazine’s headquarters were realising something had gone horribly wrong: one of the distribution vans sent to criss-cross Germany had set off for Switzerland 24 hours too early.

Within minutes, Freelancer_09 had begun tweeting the magazine’s contents. Soon, word spread. Other journalists started “retweeting” his posts. Der Spiegel frantically messaged him to make contact. He ignored them.

By 4pm he had found a scanner, and was pumping the embargoed articles out on to the internet.

Sitting helplessly in London, Rusbridger realised that the 9.30pm GMT embargo for the release of the cables looked wobbly. “You have five of the most powerful news organisations, and everything was paralysed by a little freelancer,” Rusbridger says. “We realised the story wasn’t going to hold. We had sprung a leak ourselves.”

By 6pm the Guardian and everyone else agreed just to publish, go with it. The Guardian’s production staff stood poised in front of a bank of screens. Production boss Jon Casson asked: “Will we launch?” Deputy editor Ian Katz replied: “Launch!” The word was taken up and spread instantly across the backbench, the newsroom echoing with the words: “Launch! Launch! Launch!” The world’s biggest leak had gone live.

Despite its scrappy launch, the publication of the US state department cables amounted to the biggest leak since 1971 when Daniel Ellsberg gave the Pentagon papers to the New York Times, provoking a historic court case and revealing the White House’s dirty secrets in Vietnam. This data spillage was far bigger – an unprecedented release of secret information from the heart of the world’s only superpower.

INSIDE WIKILEAKS: MY TIME WITH JULIAN ASSANGE AT THE WORLD’S MOST DANGEROUS WEBSITE by Daniel Domscheit-Berg available at Liberty Books