* Deal in Geneva offers hope of end to Ukraine crisis
* Kerry-Lavrov private chat helped break impasse
* Russia sought assurances on rights for east Ukraine
* USA needed promise pro-Russian militias to pull back
* But deal will be difficult to enforce on ground
By Arshad Mohammed and Tom Miles
WASHINGTON/GENEVA, April 18 (Reuters) - The agreement designed to pull Ukraine back from the brink of civil war had been floundering around lunchtime on Thursday, so U.S. Secretary of State John Kerry and Russia's Sergei Lavrov, a smoker, stepped outside for a private word in the open air.
They appear to have made some progress. When they came back inside, a new session of formal negotiations was hastily arranged and, finally, a deal agreed.
The agreement in Geneva was the first positive shift after weeks of mounting confrontation between the Western-backed Ukrainian government and Russian-speaking regions in the east that are challenging Kiev's rule.
The breakthrough, according to several people close to the talks who spoke on condition of anonymity, hinged on many factors, but Kerry and Lavrov each had one requirement that needed to be met if they were to come away with an agreement.
For the United States, it was a pull-back of the pro-Russian armed militants who have seized public buildings in eastern Ukraine, including early and measurable signs that it was going to happen.
"We wanted a commitment to de-escalation that we could test within days," said a U.S. participant in the talks who spoke on condition of anonymity.
For Russia, it was a commitment from the Ukrainian government to reforming the constitution so protections are enshrined for Ukraine's Russian-speaking community.
"We heeded Russia's point of view," on making sure Russian-speaking regions have a say in the constitution, said Andriy Deshchytsia, the acting Ukrainian foreign minister who attended the talks.
The deal's fragility was already in evidence on Friday.
Pro-Russian militants said they were not ready to give up the buildings they occupied, while Russia's foreign ministry described as "unacceptable" Washington's warning of more sanctions against Moscow if there are no clear signals of the deal being implemented by early next week.
In the days before the Geneva talks began, expectations were low. At a previous meeting between Lavrov and Kerry, in Paris on March 30, there was no real progress.
"We don't have high hopes for this," one Western diplomat said earlier this week of the Geneva meeting.
But the delegations arriving for the talks in Geneva's Intercontinental Hotel had a determination to do a deal that was absent at previous attempts at diplomacy, according to several people involved in the negotiations.
The reason for the new approach: blood had been spilled in eastern Ukraine hours before in clashes between pro-Russian militants and forces loyal to Kiev, and the sides knew how easily the violence could spiral.
If that happened, the potential risks were grave: a new round of sanctions against Moscow, possible disruption to Europe's supplies of Russian gas, and the danger that both the Russian military and NATO forces could be sucked in.
Diplomats said the priority in Geneva had been to stop further escalation of the conflict.
Both the U.S. and Russian delegations at the talks arrived in Geneva with draft statements, the U.S. participant said, an early sign of the willingness for a deal.
A Russian diplomatic source said the final agreement was based on the Russian draft, with amendments to take account of the other sides' views.
"This document was brought by the Russian delegation," said the source. "This was a Russian draft. Everyone started to work on it, and as a result it was agreed."
The document did not mention Moscow's intervention in Crimea, though Kerry and Ashton said they still disagreed with Russia on its annexation of the peninsula and had not changed their view that it was illegal.
People close to the talks said the progress towards a document all sides could agree on was, at times, tortuous.
On at least two occasions, reporters waiting in the lobby of the hotel were told a joint news briefing with Kerry and Catherine Ashton, the EU's chief diplomat, was about to start, only for it to be postponed.
On several occasions, Kerry could be seen leaving the corridor where the meetings were taking place and getting into the elevator to head upstairs, possibly to use the secure link to Washington, which one person close to the talks said he had at the hotel.
"The negotiations, given that they lasted seven hours, were not easy," said the Russian diplomatic source.
The U.S. participant said finding agreement on the first paragraph of the seven-paragraph document took 90 minutes, and it was not until 45 minutes before a final news conference by Kerry and Ashton that U.S. officials believed they had a deal.
Though agreement was reached against expectations, the talks ended on a note of discord that illustrated the mistrust still festering between Russia and the West.
U.S. officials had booked the hotel ballroom for the Kerry-Ashton news conference and said Lavrov would give his own briefing in the same venue afterwards.
In the event, Lavrov appeared in front of the cameras in a different room around 30 minutes before Kerry came to the podium, allowing Russia to put out its own interpretation of the agreement before its rivals. (Additional reporting by Alexei Anishchuk in Moscow, Pavel Polityuk in Kiev and Barbara Lewis in Brussels; Writing by Christian Lowe; Editing by Will Waterman)