It was a crucial shift in Ukraine's months-long standoff between Yanukovych and protesters angry that he abandoned closer ties with Europe in favor of a bailout deal with longtime ruler Russia.
If it holds, the ambitious, European-mediated agreement could be a major breakthrough in a months-long crisis over Ukraine's identity. The standoff worsened sharply this week and left scores dead and hundreds wounded in the worst violence the country has seen since it became independent in 1991.
But not all sides embraced the deal. A Russian mediator refused to sign it, and a senior Russian lawmaker criticized it as being crafted for the West.
And at the sprawling protest encampment in central Kiev, anger percolated among the thousands massed Friday night. Hardened Ukrainian protesters angry over police violence said they were determined to stand their ground until Yanukovych steps down.
Protesters booed opposition figures who took to a stage Friday evening to present the deal. One radical speaker threatened to go on an armed offensive if the opposition doesn't demand the president's resignation by Saturday morning. Others started chanting "Death to the criminal!" referring to Yanukovych.
The agreement signed Friday calls for presidential elections scheduled for March 2015 to be held no later than December. Many protesters say December is too late; they want Yanukovych out immediately.
The U.S., Russia and the 28-nation EU are deeply concerned about the future of Ukraine, a divided nation of 46 million. The country's western regions want very much to be closer to the EU and have rejected Yanukovych's authority in many cities, while eastern Ukraine favors closer ties with Russia.
Hours after the deal was signed, Ukraine's parliament voted to restore the 2004 constitution that limits presidential authority, clawing back some of the powers that Yanukovych had pushed through for himself after being elected in 2010.
Parliament then voted to fire the interior minister, Vitali Zakharchenko, who is widely despised and blamed for ordering police violence, including the snipers who killed scores of protesters Thursday in Kiev, the capital that has been nearly paralyzed by the protests.
The next order of business was Tymoshenko. Legislators voted to decriminalize the count under which she was imprisoned, meaning that she is no longer guilty of a criminal offense.
"Free Yulia! Free Yulia!" legislators chanted.
However, Yanukovych must still sign that bill into law, and then Tymoshenko's lawyers would have to ask the court for her release from prison in the eastern city of Kharkiv. The charismatic blond-braided heroine of the 2004 Orange Revolution - which also drove Yanukovych from the presidency - Tymoshenko served as prime minister and narrowly lost the 2010 presidential election to Yanukovych.
The next year, she was arrested and sentenced to seven years in prison on abuse of office charges that the West has denounced as a political vendetta.
With Yanukovych's supporters quitting his party one after another throughout the day Friday, legislators also approved an amnesty for protesters involved in violence.
Ukrainian authorities will now name a new unity government that includes top opposition figures within 10 days.
The deal was a result of two days and all-night shuttle diplomacy by top diplomats from Germany, France and Poland, who talked with the president and the opposition.
White House press secretary Jay Carney said the deal is consistent with what Washington was advocating, and that the U.S. will closely monitor whether it is fulfilled, holding out the threat of more sanctions if it's not.
But neither side won all the points it sought, and some vague conditions could ignite strong disputes down the road.
The deal calls for protesters to hand over all their weapons, withdraw from buildings they have occupied and take down the camps they have erected around the country. It is far from clear that the thousands of protesters camped out in Kiev's Independence Square - the Maidan - will pack up and go home.
"Resign! Resign! Resign!" they chanted.
"The Maidan will stand up until Yanukovych leaves," said protester Anataly Shevchuk, 29.
"I hope that the direction of the country changes, but so far the goals of the Maidan have not been achieved," said Kira Rushnitskaya, a 45-year-old protester. "Yanukovych agreed to give up powers to stay in power overall."
The agreement did not set a deadline for leaving the camp and many protesters are likely to move out slowly, both because of the emotional closeness the camp fostered and because of their distrust that the deal will actually be implemented.
Shots were heard Friday morning, a day after the deadliest violence in Ukraine's post-Soviet history. It is unclear who was targeted and whether anyone was hurt or injured.
The leader of a radical group that has been a driver of violent clashes with police, Pravy Sektor, declared Friday that "the national revolution will continue," according to the Interfax news agency.
The deal has other detractors too.
Leonid Slutsky, a Russian lawmaker who chairs the committee in charge of relations with other ex-Soviet nations, told reporters Friday that the agreement serves the interests of the West.
"We realize where and by whom this agreement has been written. It's entirely in the interests of the United States and other powers, who want to split Ukraine from Russia," he said.
Russia's Foreign Ministry issued a statement saying that Russian mediator Vladimir Lukin's refusal to sign the deal doesn't mean that Russia isn't interested in looking for a compromise to end the bloodshed.
"We will stand ready to continue helping Ukrainians normalize the situation if they ask for it," it said.
It said Ukrainians should take into account all regions in its political transition - apparently referring to the areas in Ukraine's east and south that have close economic ties to Russia, where some see the protesters as puppets of the West.
In addition to anger over the failed EU deal, protesters across the country are upset over corruption in Ukraine, the lack of democratic rights and the country's ailing economy, which just barely avoided bankruptcy with the first disbursement of a $15 billion bailout promised by Russia. The recent violence has added to Ukraine's dire economic troubles.
Jim Heintz, Efrem Lukatsky, Yuri Uvarov and Angela Charlton in Kiev, Vladimir Isachenkov in Moscow and Frank Jordans in Berlin contributed to this report.