Photo by EPA The all-nighter that kept Greece in euro ‘Time was flying by and there was no agreement in sight.’

It was just after a dinner of roast chicken and limoncello sorbet on Sunday night when talks between Greek Prime Minister Alexis Tsipras and the eurozone’s 18 other leaders got ugly.

The gathering on the top floor of the European Council building in Brussels had spent the previous six hours wading through a dense catalogue of demands — from a tax system overhaul to introducing a new civil code — that Greece would have to accept as a pre-condition to new rescue talks

Earlier in the evening, European Parliament President Martin Schulz reminded them what was at stake: “das große Ganze,” everything. But the spadework in front of the leaders was a world away from Schulz’s tone poem on Europe.

The meeting had become the ultimate all-nighter, with about two dozen of the world’s most powerful people trapped on the top floors of the drab European Council building in downtown Brussels. They traded threats and ultimatums, stormed out of rooms, wandered bleary-eyed and tie-less through the halls, occasionally slept and ultimately hashed out the fine details of not just Greece’s future but possibly Europe’s as well.

During 17 excruciating hours of talks, all the main players were also pursuing what German Chancellor Angela Merkel would later call “divergent interests.” The last-ditch summit to rescue Greece's finances had become become a forum for Europe’s competing spheres to maneuver for position: the European Commission versus the European Council, France versus Germany and northern Europe versus the south.

All wanted to leave the building, claiming victory.

Early signs of trouble

Tsipras, who arrived in Brussels earlier Sunday declaring he was committed to compromise, had already agreed to about half of the demands, showing little of the characteristic fight that has made him the left’s standard bearer in Europe.

The trouble started around 10 p.m., when the group came to the bottom of page two.

“Valuable Greek assets of [EUR 50 bn] shall be transferred to an existing external and independent fund like the Institution for Growth in Luxembourg, to be privatized over time and decrease debt,” the proposed agreement stated.

The translation: The eurozone was essentially asking Tsipras to put what was left of the state’s assets into hock — in Luxembourg. If that weren’t bad enough, the €50 billion figure seemed to have been snatched from thin air.

The Greek delegation was gobsmacked, describing the estimate as something “from another planet.” Furious, Tsipras and his advisers pointed out that the IMF’s own analysis stated that the most Greece could hope to garner from privatizations was €500 million per year.

The other leaders refused to budge.

First of all, no one really believed the Greeks' own calculations. Athens' tactics over the past months had cost it its credibility. Not only that, the Germans were insisting Greece put up state-owned collateral. Wolfgang Schäuble’s finance ministry had floated the idea on Friday, suggesting it could be connected to the Institution for Growth, an investment fund established in 2012 to invest in Greek businesses. It just so happened that state-owned German bank KfW helped manage the fund.

The Germans claimed the €50 billion estimate was based on earlier valuations of state-owned property, including energy assets and other key infrastructure. But given the state of Greece’s economy, the figure seemed high to many in the room.

Some in the room suspected Berlin’s motive was purely political. If it could claim to the German public and the Bundestag that Greece had put forth €50 billion in collateral for its rescue loans, selling the deal would be easier.

Tsipras wanted none of it. After an hour of back and forth, the two sides agreed to move on.

A long slog

But the next issue, a demand that Athens “roll back” recent legislation that overturned previous reforms demanded by Europe, was no less controversial.

Just before midnight, European Union Council President Donald Tusk called a break.

When they returned, there were new complications. Tsipras wanted more time to push through some of the legislation. The draft called for Athens to deliver on six issues, including pension reform and raising the value added tax, by Wednesday.

Earlier hopes of a quick resolution faded and a slog through the night began.

Tusk played the role of mediator, pulling Merkel, Tsipras and French President François Hollande into his office for private consultations at key junctures. In the days leading up to the summit, France had become Greece’s champion. Hollande, worried that a failure of the summit would have disastrous consequences for Europe, pushed Merkel to soften her stance.

At one point, Tsipras asked the others to let his new finance minister, Euclid Tsakalotos, join them in the private consultations. Merkel agreed but said that she wanted Schäuble there too, according to an EU source, who said that the Greek prime minister "went white." It was "a joke," the source said, describing that as the first clear sign that "Merkel was ready to compromise."

Later in the morning, Dutch Prime Minister Mark Rutte joined the breakout session with the Greeks, Merkel, Hollande and Tusk. The Dutch leader was at least as skeptical about another rescue as the Germans.

In the meantime, the other leaders waited with their delegations out of public view, two floors higher.

Finnish Prime Minister Juha Sipilä, the novice in the group, cracked jokes, telling the others to “just let me know when this thing starts again.” European Central Bank President Mario Draghi chatted with his countryman, Italian Prime Minister Matteo Renzi. A number of finance ministers loitered in the halls. Schäuble had retired to his hotel to sleep, while others rested on couches and in chairs around the building.

Commission President Jean-Claude Juncker, who took a high profile in the weeks leading up to the summit, was noticeably absent from the smaller breakout sessions led by Tusk. An EU official said Juncker spent time on the details of the final agreement and organizing a bridge loan to keep Greece afloat until its bailout could be approved.

'The final straw'

By 4 a.m., most of the open issues had been resolved. With France’s help, Greece had managed to take the option of a “timeout” from the eurozone, an idea championed by Schäuble, off the table.

But the issue of creating a Luxembourg-based trust holding and privatizing state assets still wasn’t resolved.

If there was going to be a fund, Tsipras demanded that it be in Greece, managed by Greeks. He asked for the session to be interrupted so he could consult with his delegation, leaving the room visibly angry.

“It was the final straw for him,” said a French diplomat involved in the negotiations. “We thought that the agreements we had obtained would fall into pieces because of the fund. Tsipras nearly renounced. He was under huge pressure. Time was flying by and there was no agreement in sight.”

Tusk called a five-minute break, saying if there was no deal after that, he would declare the talks a failure and an imminent Grexit. Hollande went to retrieve Tsipras, assuring the Greek leader they could find a solution with Merkel.

Back on the top floor, the three met again and were joined by Tusk and Tsakalotos. It was almost 5 a.m.

The discussion lasted for three hours, but they eventually broke the impasse. After consulting with Schäuble, Merkel agreed to base the fund in Greece as long as it remained independent. Half of the proceeds from selling assets would go towards paying down debt and the other half could be invested in the Greek economy.

The talks appeared to be back on course until Tsipras, at around 7 a.m., objected to the continued involvement of the International Monetary Fund.

One of three institutions alongside the ECB and the Commission that monitored Greece’s previous bailouts, the IMF is seen as the architect of the austerity policies that have pushed the society to the brink.

Tsipras has railed on the fund for years, both as a candidate and since he became prime minister in February. But Germany and its eurozone allies regard the IMF’s participation as essential because it limits the influence of European politics on the process of evaluating Athens’ progress.

Tsipras’ objections might have been directed more at domestic politics. The IMF’s portion of Greece’s second bailout doesn’t expire until March and it still has €16 billion it could disburse, funds Greece needs.

But just before 9 a.m., Tsipras backed down.

In return for up to €86 billion in fresh aid over the next three years, he accepted an extensive list of reforms and spending cuts that many in his party regard as a betrayal.

Maïa de La Baume, Nicholas Vinocur and Quentin Ariès contributed to this report.