A frenzy of shuttle diplomacy and hard compromises produced what may be a breakthrough in Ukraine's three-month-old political standoff, a crisis that this week prompted the deadliest violence in the country's modern history.
Protesters remain angry over corruption, crackdowns on democratic freedoms and President Viktor Yanukovych's decision to tighten trade ties with Russia instead of Europe. Radical members are threatening new violence.
But Yanukovych has ceded powers, the re-energized parliament is assuming new authority and events moved faster than ever Friday toward a possible end to the crisis.
Here's a guide to what's been happening:
The protests began in November when Yanukovych abruptly refused to sign a long-anticipated political association and free trade agreement with the European Union, opting instead for closer ties with Russia. Yanukovych is widely despised in western Ukraine, but has strong support in the Russian-speaking east, where he's from, as well as in the south.
The pro-Western demonstrators saw Yanukovych's move as a betrayal of national interests and submission to Moscow, and demanded that that he reverse his decision. Their number swelled to hundreds of thousands after a brutal crackdown by riot police. Their demands grew more radical to include Yanukovych's resignation and early elections.
His supporters in the east, meanwhile, see the protesters and the opposition as manipulated and financed by the West, and feel greater economic and cultural connection to Russia.
Peaceful rallies turned abruptly violent in January after parliament, dominated by Yanukovych supporters, passed repressive laws intended to quash the protest. Radical protesters hurled firebombs and stones at police, who retaliated with stun grenades, tear gas and rubber bullets. At least four people died and hundreds were injured.
Yanukovych made some concessions, retracting the repressive legislation and firing his prime minister. The opposition kept pushing for constitutional changes that would limit the presidential powers. The refusal by pro-Yanukovych lawmakers to endorse the amendments triggered new violence this week, when demonstrators assailed police and police fought back.
Firearms were widely used this time, resulting in a much higher death toll.
In the bloodiest day of fighting, scores were killed Thursday, including many by sniper fire. That hardened both sides.
The U.S., Russia and the EU have tried to weigh on Ukraine's future and were spooked by the spike in violence.
Moscow sees what is now Ukraine as the birthplace of Russian statehood and Russian Orthodox Christianity. Most of modern-day Ukraine came under the control of the czars in the 1700s after being part of the Polish-Lithuanian Commonwealth. Except for some western regions, which were part of Poland between the two world wars and then became part of the Soviet Union, Ukraine remained under Moscow's control until the 1991 Soviet collapse.
President Vladimir Putin sees close economic and political ties with Ukraine as essential for the success of his project to build an alliance of ex-Soviet neighbors.
Russia has done its best to derail Ukraine's pact with the EU with a mixture of trade sanctions and promises. After Yanukovych spiked the deal, Moscow offered a $15 billion bailout to help Ukraine avoid an imminent default, but so far has only provided $3 billion, freezing further disbursements pending the outcome of the ongoing strife.
After their failure to strike a deal with Yanukovych last year, EU leaders stepped up their negotiating efforts this week because of the violence on their eastern border.
All-night talks Thursday and hours of shuttling Friday - and nearly 50 draft deals - finally produced an agreement that the opposition and president signed.
Washington and the EU threatened sanctions against those responsible for the latest violence. Sanctions include travel bans and asset freezes that hit powerful tycoons whose support is essential for Yanukovych's rule.
The sharp divide between east and west has fueled fears of a messy breakup of the country. Friday's deal was aimed at avoiding that.
The deal calls for protesters to abandon camps and government buildings they have seized around the country. Some remain angry, however, and there was no sign Friday night that they planned to leave Independence Square in Kiev, the nucleus of the movement.
It also calls for constitutional changes reducing the president's powers - which the parliament passed immediately.
And it says a new government including the opposition must be formed within 10 days.
Parliament also voted to allow the release of Yanukovych's key rival, ex-Prime Minister Yulia Tymoshenko. The president would still need to sign the bill into law and the courts would need to approve her release, but that could shake up the political scene even more.
Tonight in the Daily Pulse, we're wondering: Do you think the deal passed by the EU, US and Russia will resolve political issues in Ukraine? Yes or no? Why or why not?