Under the agreement, a national unity government will be installed and a presidential poll will be held by the end of the year.
The deal, reached after mediation by EU foreign ministers, also sees electoral reform and constitutional changes.
Ukraine's parliament has voted to reduce the president's powers.
It also approved laws which could see the release of jailed opposition leader Yulia Tymoshenko.
The deal follows hours of talks and months of demonstrations on the streets of Kiev and other cities.
Dozens of protesters were killed by security forces on Thursday.
The deal has been met with scepticism by some of the thousands of protesters who remain on Independence Square in Kiev, with some saying they still did not trust President Yanukovych.
The opposition leaders who signed the deal were booed and called traitors by a crowd in Independence Square, the focal point of the protests, the BBC's Gavin Hewitt reports from Kiev.
The agreement, published by the German foreign ministry, includes the following:
By Olexiy SolohubenkoUkraine analyst. BBC News
The primary aim of any new government - which could be in place with a week or two - will be to restore peace and political stability to a country that has been on the brink of civil war.
Alongside the political changes is the challenging task of reforming the police and dismantling the whole apparatus of repression. Corrupt prosecutors and judges will have to be replaced.
And then there's the economy. The Ukrainian currency, the hryvnya, has tumbled in value. There have been reports of some shortages of petrol, bread and even cash. International ratings agencies have warned of the country defaulting on its debts.
Ukraine cannot survive without help - but where should it come from? Russia has promised a $15bn (??9.2bn; 10.9bn euros) loan, lent in dribs and drabs. Now the EU has woken up to the importance of Ukraine, the question is whether it will commit to a multibillion-pound bailout package of its own for just a single country - one which may join the EU one day, but not soon.
The agreement was later signed by Mr Yanukovych and opposition leaders Vitali Klitschko, Arseniy Yatsenyuk and Oleh Tyahnibok at the presidential administration headquarters in Kiev.
Polish Foreign Minister Radoslaw Sikorski tweeted that the deal was a "good compromise for Ukraine" which would open the way "to reform and to Europe".
Mr Sikorski told reporters on his return to Warsaw that Russia had played a constructive role in reaching the agreement.
The White House has welcomed Friday's deal, praising "the courageous opposition leaders who recognised the need for compromise".
President Barack Obama is due to speak to his Russian counterpart, Vladimir Putin, later on Friday.
UK Prime Minister David Cameron also welcomed the agreement and called on all sides in Ukraine to "get behind this deal and deliver it according to the timetable set out".
Shortly after the deal was signed, Ukraine's parliament approved the restoration of the 2004 constitution, with all but one of the 387 MPs present voting in favour.
By Mark LowenBBC News, Lviv
Any political deal between President Yanukovych and the opposition movement will have to pass the test here in Lviv. It is a city that has been at the forefront of the protests, sending busloads of demonstrators 500km east to Kiev on a nightly basis.
Lviv has always looked west rather than east: a city for centuries under Polish and Austrian rule, it only fell to the Soviets during World War Two and has remained fiercely proud of its Ukrainian identity ever since.
The writ of the Kiev government does not extend here. Every regional administration building is now under the control of the protest movement. I visited the police headquarters, taken on Tuesday night by the opposition and ransacked. At the security service office, burnt out cars lie in the courtyard. The mood here is one of defiance: that President Yanukovych must step down now.
Mr Yatsenyuk said the vote was "the first step to restore order in Ukraine".
Parliament also approved an amnesty for protesters accused of involvement in violence and voted for the dismissal of Interior Minister Vitaliy Zakharchenko.
MPs voted for a change in the law which could lead to the release of Tymoshenko, an arch-rival of Mr Yanukovych.
She was sentenced to seven years in prison in 2011 for abuse of power. Her supporters say this was simply Mr Yanukovych taking out his most prominent opponent.
"I think what we're witnessing is the collapse of this absolutely bizarre and terrible dictatorship which was building up in the country," opposition politician Andriy Shevchenko told the BBC from the floor of parliament.
Dozens of MPs from Mr Yanukovych's own Party of Regions voted for the motions, in what correspondents say will be a humiliation for the president.
Despite the agreement, isolated outbursts of violence were reported in central Kiev on Friday morning.
It remains to be seen whether the deal will be enough to placate more radical elements of the opposition, including many in the west of Ukraine, who have been demanding Mr Yanukovych's resignation.
The protests first erupted in late November when President Yanukovych rejected a landmark association and trade deal with the EU in favour of closer ties with Russia.
The deal comes after the bloodiest day since the unrest began.
Police opened fire early on Thursday after protesters tried to push them away from the makeshift camps they have been occupying in central Kiev.
The health ministry said 77 people had been killed since Tuesday, and another 577 were injured.
Ukrainian President Viktor Yanukovych and opposition leaders have signed a deal to try to end the political crisis in the country.