Saturday night had turned into Sunday morning and four days of talks over Iran's nuclear programme had already gone so far over schedule that the Geneva Intercontinental Hotel had been given over to another event.
A black tie charity ball was finishing up and singers with an after party band at a bar above the lobby were crooning out the words to a Johnny Cash song - "I fell into a burning ring of fire" - while weary diplomats in nearby conference rooms were trying to polish off the last touches of an accord. Negotiators emerged complaining that the hotel lobby smelled like beer.
At around 2:00 a.m., U.S. Secretary of State John Kerry and counterparts from Britain, China, France, Germany and Russia were brought to a conference room to approve a final text of the agreement which would provide limited relief of sanctions on Iran in return for curbs to its nuclear programme.
At the last minute, with the ministers already gathered in the room, an Iranian official called seeking changes. Negotiators for the global powers refused. Finally the ministers were given the all clear. The deal, a decade in the making, would be done at last.
Now that the interim deal is signed, talks are far from over as the parties work towards a final accord that would lay to rest all doubts about Iran's nuclear programme.
"Now the really hard part begins," Kerry told reporters. "We know this."
The deal, which represents the most important thaw between the United States and Iran in more than three decades since Iranian revolutionaries held 52 American hostages in the U.S. embassy in Tehran, very nearly did not happen.
There was still ample ground to cover on the final day, when U.S. Secretary of State John Kerry arrived, joining foreign ministers from Britain, China, France, Germany and Russia.
Officials from several of the countries were doubtful that a deal would be reached. Resentful-sounding European diplomats said their foreign minister bosses had not wanted to come unless a final text was on the table, but had felt obliged to come anyway when Russia's Sergei Lavrov showed up on Friday.