As a feeble sun came up out of a grey Brussels dawn on Monday, for a time it looked like it might be about to set on Greek hopes of clinging on to the euro.

As a feeble sun came up out of a grey Brussels dawn on Monday, for a time it looked like it might be about to set on Greek hopes of clinging on to the euro.

Alexis Tsipras was “close to walking out”, a source close to the euro zone summit said. The prime minister told other leaders that if he accepted one final bailout condition, fellow Greeks would brand him a sell-out and he “may as well not go home”.

After 14 hours of talks with German Chancellor Angela Merkel and other euro zone leaders, Tsipras was refusing to yield on the last outstanding item on an exhaustive list of loan terms that some critics say indicated Berlin wants to humiliate his leftist government and, perhaps, drive Greece from the euro.

“Maybe you need Crete? The Parthenon? The whole Acropolis maybe?” a second source quoted him asking fellow leaders after Merkel insisted he place 50 billion euros of state assets in Luxembourg, sequestered from his control to repay creditors. It is a demand some Greeks have compared to the Nazi occupation.

“If I agree to such an escrow, I can buy a ticket to fly to any other country,” Tsipras said, according to a third source.

“Because back home they’ll think that I sold out Greece.”

With markets in Europe about to open, and uncertainty over a continued cash lifeline for the Greek financial system from the European Central Bank, stalemate could have tipped Greece into a bankruptcy that would have shut it out of the common currency.

In the end, after summit chairman Donald Tusk said he would not let Tsipras and Merkel out of his office until they agreed, compromise emerged on the privatisation fund. It would be in Greece, managed by the government – under supervision – and a quarter of its revenue would go to investment not debt payments.

“There was great relief because it really was extremely close to the worst-case scenario at 6 o’clock,” the source said, adding that several of the other government leaders waiting elsewhere in the building had begun to talk about heading home.

Yet the near-collapse of the “last chance” talks underlines the fragility of a plan to refloat the Greek state. Some senior officials involved in the summit fear it may already be doomed.

“We have a 20-, maybe 30-, percent chance,” one said.

NO ROOM FOR ERROR

“This is not a done deal by any means,” said another EU official who has negotiated with Tsipras’s leftist government since it was elected in January on a promise to end austerity.

To even open formal negotiations, Tsipras must overcome party rebels to ram legislation through parliament by Wednesday. He must also secure lawmakers’ approval for the overall three-year bailout package. That may be a tall order.

“They did nothing for six months and alienated anyone who tried to help them,” the euro zone official said. “If they can start doing some of these things now, let’s see.

“But they have zero margin.”

A fourth person present at the summit said, however, that Tsipras seemed still to be grappling with technicalities of Greece’s parlous financial position, growing worse by the day as bank closures and capital controls ravage its economy.

“We had serious doubts whether Tsipras understands,” he said. IMF chief Christine Lagarde and ECB head Mario Draghi both intervened twice at the summit table to explain to him how their institutions were financing his budget and Greece’s banks.

Also constraining the 40-year-old Marxist is his reliance on a coalition, many of whom have never been, or expected to be, in government. Tusk emerged from breakout talks with Tsipras, Merkel and French President Francois Hollande suggesting a deal was ready, only for the Greek premier to return after consulting aides and allies by telephone to say: “I cannot commit.”

After accepting conditions that amount to a resignation of sovereignty over swathes of policy, Tsipras dug his heels in over the German-designed privatisation plan. But Merkel set a “red line” of her own on the same issue after forcing Tsipras to cross a host of boundaries the Greek had sworn not to breach.

With fatigue magnifying the mistrust and bickering that has marked the summit, and fearing the worst for the entire EU from an unpredictable rift in its supposedly irreversible currency union, former Polish prime minister Tusk decided to act.

They could not go until they had reached a deal, he said. One official joked that he might have threatened to lock them in his office — only he had no key.

Merkel held her ground, anxious to keep the euro zone intact but conscious that many Germans, including her own finance minister Wolfgang Schaeuble, would rather see Greece forced out.

So too did Tsipras, pointing to estimates that companies on a list to be privatised may be worth only five billion euros.

But, as one negotiator put it, the fund was “political collateral” for Merkel, who faces real challenges at home.

With the clock ticking, she and Tsipras haggled to within five billion euros on how much cash from the fund would be used to invest in Greece rather than repay debt. Tsipras came down to 15 billion euros from 25, Merkel up to 10 from nothing.

Observers were appalled that a row over a relatively small sum that may never even materialise might shatter the European project. Both seemed to feel they would be “losers” and seemed to be rehearsing arguments for pulling out, triggering Grexit.

In the end, Hollande, a tireless mediator, helped pull them back. Dutch Prime Minister Mark Rutte, working with Portugal’s Pedro Passos Coelho as leader of a group of smaller states that took even harder line with Greece, texted Tusk that 12.5 billion for investment would work for them. Merkel hesitated.

And then it was done. The deal was endorsed by a final, full meeting and announced to weary journalists just before 9 a.m.

Many international analysts questioned, however, whether the mistrust and economic damage can be repaired to see the three-year cash-for-reform programme, Greece’s third, implemented.

“This will merely delay the inevitable,” wrote Jonathan Loynes of Capital Economics. “A Greek exit from the euro zone might just have been kicked down the road a bit.”

A senior EU official said that even getting the loan deal off the ground would be tough: “This is going to be a long hard summer. Some people are saying it’s over. This is only a start.”