Under pressure to quit from mass demonstrations in Kiev, Russian-backed Yanukovich made a series of concessions to his pro-European opponents, including a national unity government and constitutional change to reduce his powers, as well as bringing forward the poll.
"There are no steps that we should not take to restore peace in Ukraine," the president said in announcing his concessions before the deal was signed. "I announce that I am initiating early elections."
He said Ukraine would revert to a previous constitution under which parliament had greater control over the make-up of the government, including the prime minister.
German Foreign Minister Frank-Walter Steinmeier, one of the EU mediators, said the deal provided for a presidential election this year, although no date had been set. The vote had been due in March 2015.
A Reuters correspondent at the signing in the presidential headquarters said Yanukovich, 63, a towering former Soviet regional transport official with two convictions for assault, did not smile during a ceremony lasting several minutes.
Opposition leader Vitaly Klitschko, a retired world boxing champion, switched his nameplate to avoid sitting next to the president. The European mediators signed as witnesses but a Russian envoy present did not sign the document.
Within an hour of the signing, the Ukrainian parliament voted to revert to a 2004 constitution that strips the head of state of some of his prerogatives.
Another of the European Union facilitators, Polish Foreign Minister Radoslaw Sikorski, described the agreement as a "good compromise for Ukraine". In a post on Twitter, he said it "gives peace a chance. Opens the way for reform and to Europe".
With Ukraine caught in a geopolitical tug-of-war between Russia and the West, at least 77 people have been killed this week in the worst violence since the independent country emerged from the wreckage of the Soviet Union in 1991.
While EU leaders applauded what European Council President Herman Van Rompuy called a "necessary compromise", there was a thunderous silence from the Kremlin, where President Vladimir Putin's spokesman declined comment.
EU foreign policy chief Catherine Ashton said implementing the accord would be crucial and would be "very challenging".
PROTESTERS STAND THEIR GROUND
Anti-government protesters remained encamped in Kiev's central Independence Square, known as the Maidan or "Euro-Maidan", and scene of the bloodshed this week.
Shortly after the signing ceremony, an open coffin carrying one of the dead from Thursday's violence, was borne across the square, as a bare-chested drummer beat out a funereal tattoo with people shouting out "Heroes don't die! Bandits out!"
Some car horns hooted and fireworks were lit to celebrate the accord, but many activists were suspicious, noting that Yanukovich had cut deals before and was still in office.
"He has to go today. We won't accept elections. He gave the order to kill, so how can we live with him now until December" said Vasily Zakharo, 40, from the western Lviv region.
"That's our opinion and that's the decision of the Maidan."
Zakharo said he had come to Kiev four days ago to join the uprising. He shaved, packed a bag, and took a baseball bat.
When his wife left for work the next day, he took the bag, left a letter on the kitchen table and walked out of the door. "I called her when I got here. She cried, of course."
Before the deal was signed, armed police briefly entered the parliament building while lawmakers were holding an emergency session but they were quickly ejected, opposition leader Arseny Yatsenyuk said. Members exchanged punches when speaker Volodymyr Rybak tried to adjourn proceedings.
Opposition deputies were angered because it would mean delaying a possible vote on a resolution pressing for constitutional changes to restrict the president's powers. The speaker left the chamber and debate continued.
Before the signing, Poland's Sikorski met a council of protesters occupying the square, and his spokesman said they agreed to let the opposition leaders to sign the agreement.
If fully implemented the agreement would be a setback for Putin, who had made tying Ukraine into a Moscow-led Eurasian Union a cornerstone of his efforts to reunite as much as possible of the former Soviet Union.
Alexei Pushkov, the head of Russia's State Duma foreign affairs committee and a member of Putin's United Russia party, told Reuters by telephone the accord was positive if it ended the violence.
"But I don't think it resolves any of the core problems which Ukraine is facing: economics, ethnic relations and governability. The opposition is rather dissimilar, and now the opposition will start to squabble between one another," he said.
There was no immediate comment from the United States, which took a back seat in the final phase of negotiations after a senior U.S. official was caught disparaging EU diplomacy on an unsecure telephone line last month.
It was unclear whether Moscow would continue paying out a promised $15 billion in aid which Putin promised after Yanukovich turned his back on a far-reaching economic deal with the EU in November.
Ratings agency Standard & Poor's cut Ukraine's credit rating for the second time in three weeks earlier on Friday, citing the increased risk of default.
S&P said latest developments in the crisis made it less likely that Ukraine would receive desperately needed Russian aid. Ukraine cancelled a planned issue of 5-year Eurobonds worth $2 billion, it told the Irish Stock Exchange where the debt would have been listed. Kiev had hoped Russia would buy the bonds to help it stave off bankruptcy.
Russia's economy minister said Moscow was still undecided on the next $2 billion instalment and was awaiting clarity on the government in Ukraine.
On financial markets, Ukraine's dollar bonds and the hryvnia currency firmed against the dollar from record lows hit this week on hopes for a deal.
However, RBS analyst Tatyana Orlova noted the country was still in dire financial straits. "This is not the end of the story. What I am reading is there is a deal but the devil is in the detail ... The urgent need is for a technocratic cabinet that could take steps to avert default," Orlova said.
The health ministry said 77 people had been killed since Tuesday afternoon, which meant at least 47 died in Thursday's clashes.
On Thursday, EU foreign ministers meeting in Brussels agreed in principle to impose targeted sanctions on Ukrainian officials responsible for the violence and threatened more if the authorities failed to restore calm.
After the Kiev accord, Ashton said a decision on the future of sanctions would depend on what the EU foreign ministers on the ground in Ukraine reported.